Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Booting app with Devise and Bundler failed #32

Closed
deepj opened this issue Nov 10, 2009 · 8 comments
Closed

Booting app with Devise and Bundler failed #32

deepj opened this issue Nov 10, 2009 · 8 comments

Comments

@deepj
Copy link

deepj commented Nov 10, 2009

I'm getting this error with Devise and Bundler. If I run app without Devise, it is okay.

root@ROOT:/c/dev/MUNI/Bakalarka/portfonica$ ruby script/server
=> Booting Mongrel
=> Rails 2.3.4 application starting on http://0.0.0.0:3000
c:/dev/MUNI/Bakalarka/portfonica/gems/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:440:in `rescue in load_missing_constant': uninitialized constant Controllers::Filters (NameError)
        from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:436:in `load_missing_constant'
        from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:in `const_missing_with_dependencies'
        from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/devise-0.4.3/lib/devise/rails/routes.rb:10:in `load_routes_with_devise!'
        from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:266:in `load!'
        from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/rails-2.3.4/lib/initializer.rb:537:in `initialize_routing'
        from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/rails-2.3.4/lib/initializer.rb:188:in `process'
        from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/rails-2.3.4/lib/initializer.rb:113:in `run'
        from c:/dev/MUNI/Bakalarka/portfonica/config/environment.rb:5:in `'
        from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
        from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `block in require'
        from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in'
        from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
        from c:/dev/MUNI/Bakalarka/portfonica/gems/gems/rails-2.3.4/lib/commands/server.rb:84:in `'
        from script/server:3:in `require'
        from script/server:3:in `'
root@ROOT:/c/dev/MUNI/Bakalarka/portfonica$

My settings is here:
http://github.com/wycats/bundler/issues#issue/88

I declared nothing Devise anywhere. No configuration in environment.rb or used an initializer. I just specified it in my Gemfile.

@josevalim
Copy link
Contributor

Devise relies on Rails require_dependency, which bundler does not use. require_dependency knows that Devise::Controllers::Filters is available at "devise/controllers/filter" and loads that file automatically. Using bundler, that file cannot be loaded and should be required manually.

@josevalim
Copy link
Contributor

After a talk with Yehuda, we agreed that the bundler preinitializer for Rails 2.3 needs to be improved, something along those lines might make it work:

require "#{File.dirname(__FILE__)}/../vendor/bundler_gems/environment"

Gem.loaded_specs.values.each do |spec|
  require_dependency File.expand_path("lib", spec.full_gem_path)
  init = File.expand_path("init", spec.full_gem_path)
  require init if File.exists?(init)
end

@deepj
Copy link
Author

deepj commented Nov 10, 2009

I've tried the code and it failed on:

c:\dev\MUNI\Bakalarka\portfonica>ruby script\server
c:/dev/MUNI/Bakalarka/portfonica/config/../config/preinitializer.rb:6:in `block in ': undefined method `require_dependency' for main:Object (NoMethodError)
        from c:/dev/MUNI/Bakalarka/portfonica/config/../config/preinitializer.rb:5:in `each'
        from c:/dev/MUNI/Bakalarka/portfonica/config/../config/preinitializer.rb:5:in `'
        from c:/dev/MUNI/Bakalarka/portfonica/config/boot.rb:28:in `load'
        from c:/dev/MUNI/Bakalarka/portfonica/config/boot.rb:28:in `preinitialize'
        from c:/dev/MUNI/Bakalarka/portfonica/config/boot.rb:10:in `boot!'
        from c:/dev/MUNI/Bakalarka/portfonica/config/boot.rb:110:in `'
        from script/server:2:in `require'
        from script/server:2:in `'

@josevalim
Copy link
Contributor

Hrm, so try it at the end of config/environment.rb.

@deepj
Copy link
Author

deepj commented Nov 10, 2009

It has not helped, it returns the same problem like in my first report.

But It is okay. It seems to be a problem in Bundler, so sorry for reporting here :).

@josevalim
Copy link
Contributor

No problem. Just one more try. Instead of "require_dependency" try "ActiveSupport::Dependencies.require_dependency" or simple adding it to load path "ActiveSupport::Dependencies.load_path <<".

@pacoguzman
Copy link

Hi!

I'm in the same problem, my configuration is the following:
boot.rb (at the end) # To run with passenger

class Rails::Boot
def run
load_initializer
extend_environment
Rails::Initializer.run(:set_load_path)
end

def extend_environment
Rails::Initializer.class_eval do
old_load = instance_method(:load_environment)
define_method(:load_environment) do
Bundler.require_env RAILS_ENV
old_load.bind(self).call
end
end
end
end

preinitializer.rb

require "#{RAILS_ROOT}/vendor/bundled_gems/environment"

And I'm tried all your options but nothings happens, I've received the following errror:

undefined method devise' for #<Class:0x7fb972d37448> /home/pacoguzman/dev/my_github/tmp/devise/vendor/bundled_gems/gems/activerecord-2.3.5/lib/active_record/base.rb:1959:inmethod_missing'
/home/pacoguzman/dev/my_github/tmp/devise/app/models/user.rb:2

Thanks

@josevalim
Copy link
Contributor

I just noticed the code above was wrong, here is the proper version:

require "#{File.dirname(FILE)}/../vendor/bundler_gems/environment"

Gem.loaded_specs.values.each do |spec|
require_dependency File.expand_path("lib", spec.full_gem_path)
init = File.expand_path("init", spec.full_gem_path)
require init if File.exists?("#{init}.rb")
end

If this does not work, try doing require "devise" in your initializer/preinitializer. If that does not work, I do not know how to help any longer. This is more a bundler issue though.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants