0

我尝试按照这个railscast将我的 3.0.10 rails 应用程序迁移到 3.1.10,但对我来说事情并没有像 Ryan 那样顺利。在解决了一些 gemset 依赖问题之后,我现在在尝试启动开发服务器时遇到了以下错误:

[nw0.0.1master (migrate_to_31)]$ rails s
=> Booting WEBrick
=> Rails 3.1.10 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.8.7/lib/rake.rb:2503:in `const_missing': uninitialized constant Sass::Plugin (NameError)
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:212:in `const_missing_from_s3_library'
    from /Users/charlesweinberger/rails_projects/nw0.0.1master/config/initializers/active_admin.rb:2:in `<top (required)>'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/engine.rb:556:in `block (2 levels) in <class:Engine>'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/engine.rb:555:in `each'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/engine.rb:555:in `block in <class:Engine>'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:30:in `run'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:54:in `each'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/application.rb:96:in `initialize!'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/charlesweinberger/rails_projects/nw0.0.1master/config/environment.rb:7:in `<top (required)>'
    from /Users/charlesweinberger/rails_projects/nw0.0.1master/config.ru:3:in `block in <main>'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/builder.rb:51:in `initialize'
    from /Users/charlesweinberger/rails_projects/nw0.0.1master/config.ru:in `new'
    from /Users/charlesweinberger/rails_projects/nw0.0.1master/config.ru:in `<main>'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/builder.rb:40:in `eval'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/builder.rb:40:in `parse_file'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/server.rb:200:in `app'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands/server.rb:46:in `app'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/server.rb:304:in `wrapped_app'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/server.rb:254:in `start'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands/server.rb:70:in `start'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands.rb:54:in `block in <top (required)>'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands.rb:49:in `tap'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands.rb:49:in `<top (required)>'
    from script/rails:37:in `require'
    from script/rails:37:in `<main>'

这是我当前的 Gemfile:

gem "pg"
gem 'pg_search'
gem 'rails', '3.1.10'
gem 'nokogiri', '1.5.5'
gem 'geocoder', '1.0.2'
gem 'devise', '1.5.3'
gem 'acts_as_api', '0.3.8'
gem 'paperclip', '~>2.4.1'
gem 'rake', '0.8.7'
gem 'omniauth', :git => 'https://github.com/intridea/omniauth.git'
gem 'fb_graph', '1.9.5'
gem 'twitter', :git => 'https://github.com/sferik/twitter.git'
gem 'jquery-rails', '>= 1.0.12'
gem 'aws-s3'
gem 'remotipart', '~> 1.0'
gem 'activeadmin'
gem 'formtastic', '~> 2.1.0'
gem "browser"
gem "httparty"
gem "thin"

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails', "  ~> 3.1.0"
  gem 'coffee-rails', "~> 3.1.0"
  gem 'uglifier'
end


group :production, :staging do
end

group :development do
    gem 'rspec-rails'
    gem 'annotate', '2.4.0'
    gem 'faker', '0.3.1'
    gem 'ruby-debug19', '0.11.6'
    gem 'nifty-generators', '0.4.6'
    gem 'silent-postgres'
end

group :test do
  gem 'rspec'
  gem 'webrat', '0.7.1'
  gem 'factory_girl_rails'
    gem "mocha", '0.9.12'
    gem 'silent-postgres'
end

而且,我在 application.rb 中启用了资产管道。这是application.rb:

require File.expand_path('../boot', __FILE__)

require 'rails/all'

# If you precompile assets before deploying to production, use this line
Bundler.require *Rails.groups(:assets => %w(development test))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)

module Nw001
  class Application < Rails::Application
    
    # Enable the asset pipeline
    config.assets.enabled = true

    # Version of your assets, change this if you want to expire all your assets
    config.assets.version = '1.0'
    
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Custom directories with classes and modules you want to be autoloadable.
    # config.autoload_paths += %W(#{config.root}/extras)

    # Only load the plugins named here, in the order given (default is alphabetical).
    # :all can be used as a placeholder for all plugins not explicitly named.
    # config.plugins = [ :exception_notification, :ssl_requirement, :all ]

    # Activate observers that should always be running.
    # config.active_record.observers = :cacher, :garbage_collector, :forum_observer

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    # config.time_zone = 'Central Time (US & Canada)'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
    # config.i18n.default_locale = :de

    # JavaScript files you want as :defaults (application.js is always included).
    # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)

    # Configure the default encoding used in templates for Ruby 1.9.
    config.encoding = "utf-8"

    # Configure sensitive parameters which will be filtered from the log file.
    config.filter_parameters += [:password]
    
    # Use SQL instead of Active Record's schema dumper when creating the database.
    # This is necessary if your schema can't be completely dumped by the schema dumper,
    # like if you have constraints or database-specific column types
    # Note, the migration that I use to install the unaccented module for pgs requires SQL
    # config.active_record.schema_format = :sql
 
 #uncomment to force ssl on localhost   
#   config.middleware.insert_before ActionDispatch::Static, "Rack::SSL"
  end
end

并且,对我的配置/环境文件进行了建议的添加。

知道如何通过未初始化的常量 Sass::Plugin (NameError) 吗???

我也尝试过使用 rails 3.1.0,它会抛出同样的错误。我也跑去rails generate active_admin:assets更新 active_admin 资产,但没有爱。

更新

在@andrew 的建议下,我创建了一个新的示例 rails3.1.10 应用程序。实际上,我所做的只是删除了我之前的 3.1 gemset;使用 rvm 创建一个新的 gemset;将 rails 3.1.10 安装到新的 gemset 中;开始使用新的 3.1 gemset;然后创建了一个新的 rails 3.1.10 应用程序。该应用程序按预期运行。

然后,我更进一步,将新应用程序 gemfile 替换为我尝试迁移到 3.1.10 的应用程序中的 gemfile。在解决了几个依赖问题并将 sqlite3 gem 重新插入 gemfile 之后,新的测试应用程序再次按预期运行。

然后,我将测试应用程序的 gemfile 复制回我尝试迁移的应用程序中,并且仍然使用新的 3.1 gemset,尝试加载开发服务器。我仍然得到一个错误,它与上面列出的错误相似,但有些不同。看看这个:

[nw0.0.1master (master)]$ rails s
=> Booting WEBrick
=> Rails 3.1.10 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:212:in `const_missing_from_s3_library': uninitialized constant Sass::Plugin (NameError)
    from /Users/charlesweinberger/rails_projects/nw0.0.1master/config/initializers/active_admin.rb:2:in `<top (required)>'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/engine.rb:556:in `block (2 levels) in <class:Engine>'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/engine.rb:555:in `each'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/engine.rb:555:in `block in <class:Engine>'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:30:in `run'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:54:in `each'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/application.rb:96:in `initialize!'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/charlesweinberger/rails_projects/nw0.0.1master/config/environment.rb:7:in `<top (required)>'
    from /Users/charlesweinberger/rails_projects/nw0.0.1master/config.ru:3:in `block in <main>'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/builder.rb:51:in `initialize'
    from /Users/charlesweinberger/rails_projects/nw0.0.1master/config.ru:in `new'
    from /Users/charlesweinberger/rails_projects/nw0.0.1master/config.ru:in `<main>'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/builder.rb:40:in `eval'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/builder.rb:40:in `parse_file'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/server.rb:200:in `app'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands/server.rb:46:in `app'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/server.rb:304:in `wrapped_app'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/server.rb:254:in `start'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands/server.rb:70:in `start'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands.rb:54:in `block in <top (required)>'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands.rb:49:in `tap'
    from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands.rb:49:in `<top (required)>'
    from script/rails:37:in `require'
    from script/rails:37:in `<main>'

这个新信息会触发任何想法吗???谢谢!

4

1 回答 1

1

问题是由我gem 'rake', "0.8.7"在 gemfile 中指定引起的。改成gem 'rake', 问题就解决了。请注意,您甚至可能不需要包含rake在 gemfile 中,因为它将作为依赖项包含在内。

于 2013-01-16T18:47:11.340 回答