uninitialized constant ActiveRecord::Railtie::ActiveRecord - ruby-on-rails

While upgrading from Ruby 2.6.6 to Ruby 3.1.3 and from Rails 5.2.6 to Rails 6.0.6, I made sure that I followed and incorporated all the changes between these 2 rails versions. I am not sure why I am getting the following error.
mw#2981eebea820:/workspaces/mw$ bundle exec rspec spec
DEPRECATION WARNING: Logger don't need to call #after_initialize directly anymore. It will be deprecated without replacement in Rails 6.1. (called from new at /workspaces/mw/config/application.rb:53)
An error occurred while loading ./spec/controllers/basic_controller_spec.rb.
Failure/Error: require 'rspec/rails'
NameError:
uninitialized constant ActiveRecord::Railtie::ActiveRecord
include ActiveRecord::Railties::ControllerRuntime
^^^^^^^^^^^^
# /usr/local/bundle/gems/activerecord-6.0.6/lib/active_record/railtie.rb:209:in `block (2 levels) in <class:Railtie>'
# /usr/local/bundle/gems/activesupport-6.0.6/lib/active_support/lazy_load_hooks.rb:71:in `class_eval'
# /usr/local/bundle/gems/activesupport-6.0.6/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
# /usr/local/bundle/gems/activesupport-6.0.6/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
# /usr/local/bundle/gems/activesupport-6.0.6/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
# /usr/local/bundle/gems/activesupport-6.0.6/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
# /usr/local/bundle/gems/activesupport-6.0.6/lib/active_support/lazy_load_hooks.rb:51:in `each'
# /usr/local/bundle/gems/activesupport-6.0.6/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
# /usr/local/bundle/gems/actionpack-6.0.6/lib/action_controller/base.rb:269:in `<class:Base>'
# /usr/local/bundle/gems/actionpack-6.0.6/lib/action_controller/base.rb:166:in `<module:ActionController>'
# /usr/local/bundle/gems/actionpack-6.0.6/lib/action_controller/base.rb:7:in `<main>'
# /usr/local/bundle/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /usr/local/bundle/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /usr/local/bundle/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
# /usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /usr/local/bundle/gems/actionview-6.0.6/lib/action_view/test_case.rb:13:in `<class:TestCase>'
# /usr/local/bundle/gems/actionview-6.0.6/lib/action_view/test_case.rb:12:in `<module:ActionView>'
# /usr/local/bundle/gems/actionview-6.0.6/lib/action_view/test_case.rb:10:in `<main>'
# /usr/local/bundle/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /usr/local/bundle/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /usr/local/bundle/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
# /usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /usr/local/bundle/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /usr/local/bundle/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /usr/local/bundle/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
# /usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /usr/local/bundle/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /usr/local/bundle/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /usr/local/bundle/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
# /usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /usr/local/bundle/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /usr/local/bundle/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /usr/local/bundle/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
# /usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# ./spec/spec_helper.rb:5:in `<main>'
# /usr/local/bundle/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /usr/local/bundle/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /usr/local/bundle/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
# /usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# ./spec/rails_helper.rb:10:in `<top (required)>'
# ./spec/controllers/basic_controller_spec.rb:1:in `require'
# ./spec/controllers/basic_controller_spec.rb:1:in `<top (required)>'

Did you make any huge jumps between Rubies? You should have moved to 2.7 first, then when that works okay, you go to 3.0 and so on. That was what I did after a huge jump broke and I did not even know where the problem is coming from. I rolled back and made little jumps and it all worked out. I understand this is not a code solution but I hope it helps anyway.

So, it turned out that the project did not have any dependency on the database so require "active_record/railtie" was dropped in the application.rb but there was an explicit call in the spec/rails_helper.rb that was referring to ActiveRecord - Object.send(:remove_const, :ActiveRecord). After dropping that call, it started working. I am not sure why this was working previously in the first place. Thanks for all the help!

Related

superclass must be an instance of Class (given an instance of Module) (TypeError) when doing `cucumber -s`

I cant seem to be able to figure out
The error logs are as follow
superclass must be an instance of Class (given an instance of Module) (TypeError)
/home/asus/code/ruby-project/cucumber/config/application.rb:11:in `<module:Cucumber>'
/home/asus/code/ruby-project/cucumber/config/application.rb:9:in `<top (required)>'
/home/asus/code/ruby-project/cucumber/config/environment.rb:2:in `require_relative'
/home/asus/code/ruby-project/cucumber/config/environment.rb:2:in `<top (required)>'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-rails-2.5.1/lib/cucumber/rails.rb:12:in `require'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-rails-2.5.1/lib/cucumber/rails.rb:12:in `<top (required)>'
/home/asus/code/ruby-project/cucumber/features/support/env.rb:7:in `require'
/home/asus/code/ruby-project/cucumber/features/support/env.rb:7:in `<top (required)>'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/glue/registry_and_more.rb:122:in `require'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/glue/registry_and_more.rb:122:in `load_code_file'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/runtime/support_code.rb:142:in `load_file'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/runtime/support_code.rb:81:in `block in load_files!'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/runtime/support_code.rb:80:in `each'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/runtime/support_code.rb:80:in `load_files!'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/runtime.rb:278:in `load_step_definitions'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/runtime.rb:74:in `run!'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/cli/main.rb:29:in `execute!'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/bin/cucumber:9:in `<top (required)>'
/home/asus/.rbenv/versions/3.1.2/bin/cucumber:25:in `load'
/home/asus/.rbenv/versions/3.1.2/bin/cucumber:25:in `<top (required)>'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/cli/exec.rb:58:in `load'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/cli/exec.rb:58:in `kernel_load'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/cli/exec.rb:23:in `run'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/cli.rb:486:in `exec'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/cli.rb:31:in `dispatch'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/cli.rb:25:in `start'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/exe/bundle:48:in `block in <top (required)>'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/exe/bundle:36:in `<top (required)>'
/home/asus/.rbenv/versions/3.1.2/bin/bundle:25:in `load'
/home/asus/.rbenv/versions/3.1.2/bin/bundle:25:in `<main>'
The application.rb is as followed
require_relative "boot"
require "rails/all"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Cucumber
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
end
end
There are threads with similar issues (ruby on rails : <top (required)>': superclass must be a Class (Symbol given) (TypeError)), I am not sure it can be applied in this case. I tried to reinstall rails, downgrading cucumber-rails. The issue is still persisted.
I guess the problem is that you named your Ruby on Rails application Cucumber while having the cucumber gem installed too. And that this confuses Ruby.
I suggest naming your Ruby on Rails application differently and not using the same name as a well-known gem.

Bundler.require fails in clean Rails project

My rails app fails to load when I have the following line in application.rb:
Bundler.require(:default, Rails.env)
I get the following error:
.rvm/gems/ruby-2.0.0-p353#global/gems/railties-4.0.2/lib/rails/initializable.rb:13:in `[]': no implicit conversion of Symbol into Integer (TypeError)
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#global/gems/railties-4.0.2/lib/rails/initializable.rb:13:in `initialize'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#global/gems/railties-4.0.2/lib/rails/initializable.rb:85:in `new'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#global/gems/railties-4.0.2/lib/rails/initializable.rb:85:in `initializer'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#rails-4.0/gems/rolify-3.3.0/lib/rolify/railtie.rb:6:in `<class:Railtie>'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#rails-4.0/gems/rolify-3.3.0/lib/rolify/railtie.rb:5:in `<module:Rolify>'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#rails-4.0/gems/rolify-3.3.0/lib/rolify/railtie.rb:4:in `<top (required)>'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#global/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#global/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#global/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#global/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#rails-4.0/gems/rolify-3.3.0/lib/rolify.rb:1:in `<top (required)>'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `require'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `each'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `block in require'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `each'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `require'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler.rb:131:in `require'
from /Users/gerardkelly/Web Development/Rails Apps/Rails 4/po-app/config/application.rb:5:in `<top (required)>'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#global/gems/railties-4.0.2/lib/rails/commands.rb:74:in `require'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#global/gems/railties-4.0.2/lib/rails/commands.rb:74:in `block in <top (required)>'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#global/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap'
from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353#global/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Looks as though it's complaining about the params being sent in - which is odd because this is pre-baked Rails stuff. Note that the Bundler.require is application.rb:5 which its complaining about.
I'm on Rails 4, Ruby 2.0.0
Looks like the rollify gem you are using (so it's not clean rails project :P) has some issues in rails 4.x series.
Check this out: https://github.com/EppO/rolify/pull/218 there is a fork that already fixes that.

Tests are running on my Ubuntu pc, but not on my Mac OS X Lion 10.7.3, Ruby 1.9.3, Rails 3.2.1

I have project in Dropbox and two running laptops: one with Ubuntu and one with Mac OS X Lion 10.7.3. When I try to run either rspec or cucumber on ubuntu they are running well, but when I try to run tests on Mac I have the same errors in
config/application.rb:13: Bundler.require(*Rails.groups(:assets => %w(development test)))
For cucumber:
Using the default profile...
undefined method `gsub' for nil:NilClass (NoMethodError)
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#global/gems/bundler-1.1.1/lib/bundler/runtime.rb:77:in `rescue in rescue in block in require'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#global/gems/bundler-1.1.1/lib/bundler/runtime.rb:72:in `rescue in block in require'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#global/gems/bundler-1.1.1/lib/bundler/runtime.rb:62:in `block in require'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#global/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in `each'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#global/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in `require'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#global/gems/bundler-1.1.1/lib/bundler.rb:119:in `require'
/Users/sergey/Dropbox/rails_projects/payforapps/config/application.rb:13:in `<top (required)>'
/Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/sergey/Dropbox/rails_projects/payforapps/config/environment.rb:2:in `<top (required)>'
/Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/sergey/Dropbox/rails_projects/payforapps/features/support/env.rb:11:in `block in <top (required)>'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/spork-0.9.0/lib/spork.rb:24:in `prefork'
/Users/sergey/Dropbox/rails_projects/payforapps/features/support/env.rb:6:in `<top (required)>'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/cucumber-1.1.9/lib/cucumber/rb_support/rb_language.rb:129:in `load'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/cucumber-1.1.9/lib/cucumber/rb_support/rb_language.rb:129:in `load_code_file'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:171:in `load_file'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:82:in `each'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:82:in `load_files!'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/cucumber-1.1.9/lib/cucumber/runtime.rb:175:in `load_step_definitions'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/cucumber-1.1.9/lib/cucumber/runtime.rb:40:in `run!'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:43:in `execute!'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:20:in `execute'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/cucumber-1.1.9/bin/cucumber:14:in `<top (required)>'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/bin/cucumber:19:in `load'
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/bin/cucumber:19:in `<main>'
For rspec:
No DRb server is running. Running in local process instead ...
/Users/sergey/.rvm/gems/ruby-1.9.3-p125#global/gems/bundler-1.1.1/lib/bundler/runtime.rb:77:in `rescue in rescue in block in require': undefined method `gsub' for nil:NilClass (NoMethodError)
from /Users/sergey/.rvm/gems/ruby-1.9.3-p125#global/gems/bundler-1.1.1/lib/bundler/runtime.rb:72:in `rescue in block in require'
from /Users/sergey/.rvm/gems/ruby-1.9.3-p125#global/gems/bundler-1.1.1/lib/bundler/runtime.rb:62:in `block in require'
from /Users/sergey/.rvm/gems/ruby-1.9.3-p125#global/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in `each'
from /Users/sergey/.rvm/gems/ruby-1.9.3-p125#global/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in `require'
from /Users/sergey/.rvm/gems/ruby-1.9.3-p125#global/gems/bundler-1.1.1/lib/bundler.rb:119:in `require'
from /Users/sergey/Dropbox/rails_projects/payforapps/config/application.rb:13:in `<top (required)>'
from /Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/sergey/Dropbox/rails_projects/payforapps/config/environment.rb:2:in `<top (required)>'
from /Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/sergey/Dropbox/rails_projects/payforapps/spec/spec_helper.rb:10:in `block in <top (required)>'
from /Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/spork-0.9.0/lib/spork.rb:24:in `prefork'
from /Users/sergey/Dropbox/rails_projects/payforapps/spec/spec_helper.rb:4:in `<top (required)>'
from /Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/sergey/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/sergey/Dropbox/rails_projects/payforapps/spec/controllers/static_pages_controller_spec.rb:1:in `<top (required)>'
from /Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `load'
from /Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `block in load_spec_files'
from /Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `map'
from /Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `load_spec_files'
from /Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/rspec-core-2.9.0/lib/rspec/core/command_line.rb:22:in `run'
from /Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:66:in `rescue in run'
from /Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:62:in `run'
from /Users/sergey/.rvm/gems/ruby-1.9.3-p125#payforapps321/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:10:in `block in autorun'
How can I fix it? Any help appreciated. Thank you.
The problem was in two gems in my Gemfile:
gem 'rb-inotify', '0.8.8'
gem 'libnotify', '0.5.9'
These gems are compatible only with Ubuntu as I understand.
UPD:
You should OS-specific gems to groups. Add all OS X specific gems to a darwin group in the Gemfile, and all Linux specific gems to a linux group:
# Gemfile
group :darwin do
gem 'rb-fsevent'
gem 'growl'
end
group :linux do
gem 'rb-inotify'
end
To require the appropriate gems in the right environment, add the following to config/application.rb:
platform = RUBY_PLATFORM.match(/(linux|darwin)/)[0].to_sym
Bundler.require(platform)
See https://github.com/bbatsov/rails-style-guide#bundler for more info about bundler here.
There was a problem with my gem .
update the bundler
Read the error properly, it will tell you which gem is the culprit.
Thing is that not all gems are compatible with OS .

The has_many_polymorphs plugin is giving me this error

This is the error in my logs when I try to create a new model:
/rubyprograms/dreamstill/vendor/plugins/has_many_polymorphs/lib/has_many_polymorphs/configuration.rb:7: Configuration is not a class (TypeError)
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/dependencies.rb:239:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/dependencies.rb:239:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/dependencies.rb:239:in `require'
from /rubyprograms/dreamstill/vendor/plugins/has_many_polymorphs/lib/has_many_polymorphs.rb:23
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/dependencies.rb:239:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/dependencies.rb:239:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/dependencies.rb:239:in `require'
from /rubyprograms/dreamstill/vendor/plugins/has_many_polymorphs/init.rb:2
from /Library/Ruby/Gems/1.8/gems/railties-3.0.4/lib/rails/plugin.rb:81
from /Library/Ruby/Gems/1.8/gems/railties-3.0.4/lib/rails/initializable.rb:25:in `instance_exec'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.4/lib/rails/initializable.rb:25:in `run'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.4/lib/rails/initializable.rb:50:in `run_initializers'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.4/lib/rails/initializable.rb:49:in `each'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.4/lib/rails/initializable.rb:49:in `run_initializers'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.4/lib/rails/application.rb:134:in `initialize!'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.4/lib/rails/application.rb:77:in `send'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.4/lib/rails/application.rb:77:in `method_missing'
from /rubyprograms/dreamstill/config/environment.rb:5
from /Library/Ruby/Gems/1.8/gems/railties-3.0.4/lib/rails/application.rb:103:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.4/lib/rails/application.rb:103:in `require_environment!'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.4/lib/rails/commands.rb:16
from script/rails:6:in `require'
from script/rails:6
It's from the has_many_polymorphs plugin...
here is config/environment.rb:
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Dreamstill::Application.initialize!
This is /rubyprograms/dreamstill/vendor/plugins/has_many_polymorphs/lib/has_many_polymorphs/configuration.rb:
module Rails #:nodoc:
class Configuration
def has_many_polymorphs_options
::HasManyPolymorphs.options
end
def has_many_polymorphs_options=(hash)
::HasManyPolymorphs.options = HashWithIndifferentAccess.new(hash)
end
end
end
The quick answer:
Your has_many_polymorphs plugin is broken. And I think you've included it in your environment.rb file on LINE 5
UPD
as you can see /rubyprograms/dreamstill/vendor/plugins/has_many_polymorphs/lib/has_many_polymorphs.rb:23 there is an error in has_many_polymorphs.rb file n line 23. Fix it :D. Or don't use broken plugins.
rails plugin remove has_many_polymorphs

Getting an uninitialized constant error with RSpec. Have no idea what's causing it

I'm using RSpec for testing and when I left work Friday afternoon, my tests were passing. But when I went home and synced my repository, the tests failed on my laptop. Now back at work, the tests are failing still. Don't believe its my code since running rspec by itself returns an error and spork won't even start up. When I try to start Spork, I get the following error message:
Using RSpec
Loading Spork.prefork block...
uninitialized constant ActionView::Template::Handlers::ERB::ENCODING_FLAG (NameError)
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/rspec-core-2.2.1/lib/rspec/core/backward_compatibility.rb:20:in `const_missing'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template/handlers/erb.rb:85:in `<class:ERB>'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template/handlers/erb.rb:70:in `<module:Handlers>'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template/handlers/erb.rb:28:in `<class:Template>'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template/handlers/erb.rb:27:in `<module:ActionView>'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template/handlers/erb.rb:6:in `<top (required)>'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template/handlers.rb:10:in `extended'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template.rb:99:in `extend'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template.rb:99:in `<class:Template>'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template.rb:8:in `<module:ActionView>'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template.rb:6:in `<top (required)>'
<internal:lib/rubygems/custom_require>:29:in `require'
<internal:lib/rubygems/custom_require>:29:in `require'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_view/template/resolver.rb:3:in `<top (required)>'
<internal:lib/rubygems/custom_require>:29:in `require'
<internal:lib/rubygems/custom_require>:29:in `require'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_view/testing/resolvers.rb:1:in `<top (required)>'
<internal:lib/rubygems/custom_require>:29:in `require'
<internal:lib/rubygems/custom_require>:29:in `require'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/rspec-rails-2.2.1/lib/rspec/rails/view_rendering.rb:1:in `<top (required)>'
<internal:lib/rubygems/custom_require>:29:in `require'
<internal:lib/rubygems/custom_require>:29:in `require'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/rspec-rails-2.2.1/lib/rspec/rails.rb:9:in `<top (required)>'
<internal:lib/rubygems/custom_require>:33:in `require'
<internal:lib/rubygems/custom_require>:33:in `rescue in require'
<internal:lib/rubygems/custom_require>:29:in `require'
/home/jeff/Projects/Rails/vahsfbhistory/spec/spec_helper.rb:10:in `block in <top (required)>'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/spork-0.8.4/lib/spork.rb:23:in `prefork'
/home/jeff/Projects/Rails/vahsfbhistory/spec/spec_helper.rb:5:in `<top (required)>'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/spork-0.8.4/lib/spork/test_framework.rb:138:in `load'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/spork-0.8.4/lib/spork/test_framework.rb:138:in `block (2 levels) in preload'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/spork-0.8.4/lib/spork/app_framework.rb:64:in `preload'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/spork-0.8.4/lib/spork/test_framework.rb:134:in `block in preload'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/spork-0.8.4/lib/spork.rb:67:in `exec_prefork'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/spork-0.8.4/lib/spork/test_framework.rb:120:in `preload'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/spork-0.8.4/lib/spork/run_strategy/forking.rb:25:in `preload'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/spork-0.8.4/lib/spork/runner.rb:74:in `run'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/spork-0.8.4/lib/spork/runner.rb:9:in `run'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/spork-0.8.4/bin/spork:10:in `<top (required)>'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/bin/spork:19:in `load'
/home/jeff/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/bin/spork:19:in `<main>'
Anyone know what could be causing this?
I ran into this problem. In the spec_helper.rb try replacing:
require "rails"
with
require "rails/all"
Worked in my situation.
You need to initialize environment, add this line to spec_helper.rb:
require File.expand_path("../../config/environment", __FILE__)
You may encounter this issue if you're trying to use rspec-rails in a non-rails project. In that case using require "rails/all" is not an option because it'd require ActiveRecord stuff leaving you with:
ActiveRecord::ConnectionNotEstablished: No connection pool with 'primary' found.
Instead you can fix this issue with:
require "action_controller/railtie"
If it's not a Rails app and you don't want to include all of Rails, add this to your spec_helper.rb:
require 'action_view'

Resources