简体   繁体   中英

Error when trying to run rails server after migrating from 3.0.10 to 3.1.19

I tried to follow this railscast to migrate my 3.0.10 rails app to 3.1.10, but things didn't go as smoothly for me as they did for Ryan. After working through some gemset dependency problems I now hit the following error when trying to launch the development server:

[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>'

Here is my current 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

And, I've enabled the asset pipeline in application.rb. Here is 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

And, made the suggested additions to my config/environments files.

Any idea how to get passed the uninitialized constant Sass::Plugin (NameError)???

I've also tried to use rails 3.1.0, which throws the same error. I also ran rails generate active_admin:assets to update the active_admin assets, but no love.

UPDATE

On the suggestion of @andrew I created a new sample rails3.1.10 application. Actually, what I did was delete my previous gemset for 3.1; create a new gemset using rvm; installed rails 3.1.10 into the new gemset; started using that new 3.1 gemset; and then created a new rails 3.1.10 app. The app ran as expected.

I then took things one step further by replacing the new apps gemfile with the gemfile from the app that I'm trying to migrate to 3.1.10. After working through a couple of dependency issues and reinserting the sqlite3 gem into the gemfile, again the new test app ran just as expected.

I then copied the test apps' gemfile back into the app that I'm trying to migrate and, still using the new 3.1 gemset, tried to load the development server. I still got an error, and it is similar to the error listed above, but it is somewhat different. Check it out:

[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>'

Does this new info trigger any ideas??? Thanks!

Problem was caused by me specifying gem 'rake', "0.8.7" in the gemfile. Changed it to gem 'rake' , and that solved the problem. Note, you probably don't even need to include rake in the gemfile as it will be included as a dependency.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM