Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 2.x mongrel won't start after upgrading to rails 3. -- mongrel_rails (MissingSourceFile)

After upgrading my Rails install to Rails 3 on OS X, I’ve had problems running my Rails 2.x development sites with Mongrel. WEBrick seems to work, but I really would like to have the nice output of Mongrel for debugging.

After running $ script/server I get this:

/Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load': no such file to load -- mongrel_rails (MissingSourceFile)
from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/commands/servers/mongrel.rb:64
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:49:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:49:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:49:in `gem_original_require'

So far, here’s what I’ve tried:

$ sudo gem update system
$ sudo gem update
$ sudo gem uninstall mongrel
$ sudo gem install mongrel --include-dependencies
$ which mongrel_rails

/usr/bin/mongrel_rails

$ mongrel_rails start

→ Success, but no stdout

$ which mongrel_rails

/usr/bin/mongrel_rails

$ rails _2.0.2_ test

→ Fresh application has same problem.

  • OS: OS X.6.x
  • Rails: 3.0.5 (problems are with Rails 2.x apps)
  • gem -v: 1.6.1
  • Mongrel: mongrel (1.1.5)

I’ve read EVERY Google result on "-- mongrel_rails (MissingSourceFile)"; there aren’t many.

Can anyone here tell me how to proceed in debugging this? Thanks!

UPDATE:

I’ve now tried installing older versions of the gem and specifying those in my Rails 2.x site’s config/environment.rb file. I’ve tried 1.1.5, 1.1.4, and 1.2.0pre.

None of these makes the slightest bit of difference.

Since the executable in in usr/bin I’m wondering if it’s a file ownership issue that got screwed up on my Rails 3 install and if one of the files isn’t getting my paths when it runs?

/Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb is owned by admin / root, so that should be OK, right?

Could it be a problem with active_support!?

Here’s the code from dependencies.rb that’s throwing the error:

484 class Object
485   
486  alias_method :load_without_new_constant_marking, :load
487  
488  def load(file, *extras) #:nodoc:
489    Dependencies.new_constants_in(Object) { super(file, *extras) }
490  rescue Exception => exception  # errors from loading file
491     exception.blame_file! file
492     raise
493   end
...  

This is getting a file not found error, so it’s not looking where I know the file to be… Running mongrel_rails on command line works… Which mongrel_rails shows it in usr/bin, So what’s the problem?

like image 827
Techism Avatar asked Dec 02 '22 03:12

Techism


1 Answers

I have got the same problem and found the reason.

This happens because new version of RubyGems(1.6.2) does not add 'any_gem/bin' to ruby load path ($LOAD_PATH) when you require "any_gem".

For example in RubyGems version = 1.4.1 this works fine. After I require 'mongrel' I can see in load path next:

  • ...rvm/gems/ruby-1.8.7-p330/gems/mongrel-1.1.5/bin
  • ...rvm/gems/ruby-1.8.7-p330/gems/mongrel-1.1.5/lib
  • ...rvm/gems/ruby-1.8.7-p330/gems/mongrel-1.1.5/ext

With new version (1.6.2) I can see only:

  • ...rvm/gems/ruby-1.8.7-p330/gems/mongrel-1.1.5/lib
  • ...rvm/gems/ruby-1.8.7-p330/gems/mongrel-1.1.5/ext

That's why ruby cannot find 'mongrel_rails'.

like image 189
Max Shytikov Avatar answered Dec 04 '22 04:12

Max Shytikov