0

I have a Rails 2 project that I am trying to upgrade to Rails 3, but getting some issues with bundler.

When I run "rake", it runs the tests just fine. But when I run "bundle exec rake" it fails to find a constant.

The error is this:

/Users/kimptoc/.rvm/gems/ruby-1.8.7-p330@p-borisbikestats-pre-rails3/gems/activesupport-2.3.9/lib/active_support/dependencies.rb:131:in `const_missing': uninitialized constant Rails::Plugin::OpenID (NameError)
    from /Users/kimptoc/Documents/ruby/borisbikes/borisbikestats.pre3/vendor/plugins/open_id_authentication/init.rb:16:in `evaluate_init_rb'
    from /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330@p-borisbikestats-pre-rails3/gems/activesupport-2.3.9/lib/active_support/callbacks.rb:182:in `call'
    from /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330@p-borisbikestats-pre-rails3/gems/activesupport-2.3.9/lib/active_support/callbacks.rb:182:in `evaluate_method'
    from /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330@p-borisbikestats-pre-rails3/gems/activesupport-2.3.9/lib/active_support/callbacks.rb:166:in `call'
    from /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330@p-borisbikestats-pre-rails3/gems/activesupport-2.3.9/lib/active_support/callbacks.rb:90:in `run'
    from /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330@p-borisbikestats-pre-rails3/gems/activesupport-2.3.9/lib/active_support/callbacks.rb:90:in `each'
    from /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330@p-borisbikestats-pre-rails3/gems/activesupport-2.3.9/lib/active_support/callbacks.rb:90:in `send'
    from /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330@p-borisbikestats-pre-rails3/gems/activesupport-2.3.9/lib/active_support/callbacks.rb:90:in `run'
    from /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330@p-borisbikestats-pre-rails3/gems/activesupport-2.3.9/lib/active_support/callbacks.rb:276:in `run_callbacks'
    from /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330@p-borisbikestats-pre-rails3/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:51:in `send'
    from /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330@p-borisbikestats-pre-rails3/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:51:in `run_prepare_callbacks'
    from /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330@p-borisbikestats-pre-rails3/gems/rails-2.3.9/lib/initializer.rb:631:in `prepare_dispatcher'
    from /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330@p-borisbikestats-pre-rails3/gems/rails-2.3.9/lib/initializer.rb:185:in `process'
    from /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330@p-borisbikestats-pre-rails3/gems/rails-2.3.9/lib/initializer.rb:113:in `send'
    from /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330@p-borisbikestats-pre-rails3/gems/rails-2.3.9/lib/initializer.rb:113:in `run'
    from /Users/kimptoc/Documents/ruby/borisbikes/borisbikestats.pre3/config/environment.rb:9
    from ./test/test_helper.rb:2:in `require'
    from ./test/test_helper.rb:2

I have these gems installed:

$ gem list

*** LOCAL GEMS ***

actionmailer (2.3.9)
actionpack (2.3.9)
activerecord (2.3.9)
activeresource (2.3.9)
activesupport (2.3.9)
authlogic (2.1.3)
bundler (1.0.7)
gravtastic (2.2.0)
linecache (0.43)
mocha (0.9.10)
newrelic_rpm (2.13.4)
parseexcel (0.5.2)
rack (1.1.0)
rack-openid (1.1.1)
rails (2.3.9)
rake (0.8.7)
ruby-debug-base (0.10.5.jb2, 0.10.4)
ruby-debug-ide (0.4.15)
ruby-openid (2.1.8, 2.1.7, 2.0.4)
sqlite3-ruby (1.3.2)

The bundler Gemfile is as follows:

source 'http://rubygems.org'

#gem 'rails', '3.0.3'
gem "rails", "2.3.9"
gem "activesupport", "2.3.9"
gem "ruby-openid", "2.1.7", :require => "openid"
#gem "authlogic-oid", "1.0.4"

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3-ruby', :require => 'sqlite3'

gem "authlogic", "= 2.1.3"
gem "newrelic_rpm"
#  gem "facebooker"
gem "parseexcel"
gem 'gravtastic', '= 2.2.0'
gem "rack-openid", '=1.1.1', :require => 'rack/openid'

# not sure what this does...
gem "mocha"

I have these plugins installed:

2dc_jqgrid      
authlogic_openid    
open_id_authentication  
squirrel

I see these similar questions:

Missing a constant on load.. how can i get around this?

and

Requiring gem in Rails 3 Controller failing with "Constant Missing"

But their solutions dont seem to work for my situation.

I am guessing the issue is around the plugins, but my ruby-fu is too weak.

UPDATE

Getting closer, I think.

Seems like using the plugin version of authlogic_openid is not the current route - so have switched to use the authlogic-oid gem. Also seemed to have an old/different version of open_id_authentication - so updated that.

Now the exception/stack trace is as follows:

/Users/kimptoc/.rvm/gems/ruby-1.8.7-p330@p-borisbikestats-pre-rails3/gems/activerecord-2.3.9/lib/active_record/base.rb:1998:in `method_missing': undefined method `openid_required_fields=' for #<Class:0x1036cccb8> (NoMethodError)
    from /Users/kimptoc/Documents/ruby/borisbikes/borisbikestats.pre3/app/models/user.rb:21
    from /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330@p-borisbikestats-pre-rails3/gems/authlogic-2.1.6/lib/authlogic/acts_as_authentic/base.rb:33:in `acts_as_authentic'
    from /Users/kimptoc/Documents/ruby/borisbikes/borisbikestats.pre3/app/models/user.rb:16

Using these gems now:

authlogic (2.1.6)
authlogic-oid (1.0.4)
rack-openid (1.2.0)
ruby-openid (2.1.8)

Seems like an issue with authlogic-oid not being loaded/init'd... my Gemfile looks like this:

gem "ruby-openid", :require => "openid"
gem "authlogic-oid", :require => "authlogic_openid"
gem "authlogic"
gem "rack-openid", :require => 'rack/openid'

Also, the app/openid login stuff is now not working - so I guess I need to play with these the versions of these gems some more...

Thanks in advance, Chris

Community
  • 1
  • 1
Chris Kimpton
  • 5,546
  • 6
  • 45
  • 72

1 Answers1

1

(Interesting project name!)

I think from the stack trace that the plugin open_id_authentication is not compatible with Rails 2, and will require Rails 3 to function.

If you're upgrading to Rails 3, I'd get the project to the point where you are using the new versions of Active* and Rails before attempting a fix just for one plugin.

stef
  • 14,172
  • 2
  • 48
  • 70
  • I'd agree, but I think you got your versions of Rails around the wrong way. By the looks of things it's not compatible with Rails *THREE* and used to be compatible with *TWO*. – Ryan Bigg Jan 01 '11 at 10:50
  • Hmm - but you don't yet have Rails 3 in the stack - you're running with Rails 2.3.9. This looks like you have a gem incompatibility in that case - if rake spec works and bundle rake spec fails, then I think you need to go through all of your system gems, compare them to the versions that bundler is putting in the .gems directory and 'pin' the version numbers in your app. Eg. `gem 'rack', '=1.1.0'`. You're probably getting a newer version of a gem than the one that you need, so it's failing. – stef Jan 01 '11 at 11:10
  • Thanks for the ideas - stef is correct, still on rails2 in this branch of the code - seeing if fixing the bundler issues help me in my rails3 branch. Tried remvoing the open_id_auth plugin and that did fix the issue - but I think I need it for my login stuff :( Seems I have broken my openid auth at the moment - perhaps fixing that will help. – Chris Kimpton Jan 02 '11 at 12:49