Rails 2.x mongrel does not start after upgrading to rails 3. - mongrel_rails (MissingSourceFile)

After upgrading my Rails installation to Rails 3 on OS X, Ive had problems with Rails 2.x development sites with Mongrel. WEBrick seems to work, but I really would like to get some good Mongrel output for debugging.

After running $ script/server I get the following:

 /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, this is what Ive 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 not stdout

 $ which mongrel_rails 

/usr/bin/mongrel_rails

 $ rails _2.0.2_ test 

→ The new application has the same problem.

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

Ive read EVERY Google result on "- mongrel_rails (MissingSourceFile)"; there are many.

Can someone here tell me how to continue debugging? Thanks!

UPDATE:

Now I tried to install older versions of the gems and specify them in the Rails 2.x config/environment.rb file. Ive tried 1.1.5, 1.1.4 and 1.2.0pre.

None of this makes the slightest difference.

Since the in in usr/bin im executable is wondering if there was a file permissions issue that was messed up on my Rails 3, and if one of the files doesn’t get my paths when it starts?

/Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb belongs to admin / root, so this should be OK, right?

Could this be a problem with active_support !?

Here is the code from dependencies.rb that throws an 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 leads to a file error not found, so I am not looking for it, where I know what the file will be ... Running mongrel_rails on the command line works ... Which mongrel_rails shows this in usr/bin , So what's the problem?

+4
source share
8 answers

You need to add "/ usr / bin" to your boot path. Perhaps something in it broke?

The best way to fix this is to add:

 $:.push("/usr/bin/") 

Somewhere before this breaks. Perhaps by itself in the config / preinitializer.rb file if you don't have one.

+4
source

I have the same problem and I found the reason.

This is because the new version of RubyGems (1.6.2) does not add "any_gem / bin" to the ruby ​​load path ($ LOAD_PATH) when you need "any_gem".

For example, in RubyGems version = 1.4.1 this works fine. After I require "mongrel", I see the following boot path:

  • ... 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 / Library
  • ... rvm / gems / ruby-1.8.7-p330 / gems / mongrel-1.1.5 / ext

With the new version (1.6.2), I see only:

  • ... RVM / gems / ruby-1.8.7-P330 / gems / mongrel-1.1.5 / Library
  • ... RVM / gems / ruby-1.8.7-P330 / gems / mongrel-1.1.5 / int

This is why the ruby ​​cannot find "mongrel_rails".

+6
source

OK, here is ONE answer. I got mongrel to download ... but it is hacked and does not solve the real problem ... but, at least for NOW, I can return to work on this project.

That's what I did ... YES .. HAIKA.

I edited a file throwing an error ... dependencies.rb

I added a hook to call a specific path to mongrel rails if it was the file that he was trying to load.

 def load(file, *extras) #:nodoc: if file == "mongrel_rails" file ="/usr/bin/mongrel_rails" end Dependencies.new_constants_in(Object) { super(file, *extras) } rescue Exception => exception # errors from loading file exception.blame_file! file raise end 

Again, I really would like to fix the main problem here ... but that at least allowed me to boot.

+3
source

I would definitely consider using RVM to run multiple versions of gem at the same time. I came across a lot of quirks when I tried to execute several versions, for example, installing sudo gem.

Now it is as simple as rvm ree@my _app_1 , and installs completely separate gems there, then switches to another application and uses rvm ree@my _app_2

ree is an alias for my version of the ruby ​​version of the enterprise, you can just as easily do it with ruby ​​1.9, 1.8.x, etc.

Every root directory of my application has a .rvmrc file that just reads:

 rvm ree@my _app --create 

So every time I switch to this directory, gemset automatically changes for me.

+2
source

I did not know that there was support for the Rails 3 mongrel.

Most people use Thin (you can enable it by specifying gem 'thin' in the Gemfile and then running rails server thin / Webrick these days.

If this is for hosting, then nginx and Passenger will help with this.

+1
source

I ran into the same problem - I got my application by running "mongrel_rails" from the project directory (instead of "script / server").

+1
source

This is a thread where you can find the best answer to the mongrel_rails (MissingSourceFile) error. I just want to conclude here how I solved the problem using the material in this topic.

The simplest solution I could figure out how to do this is to lower RubyGems by typing

 (sudo) gem update --system 1.4.1 

This allows me to run the old application 2.1.0 (thanks to Max Shytikov), but there are probably a lot of fixes that I am missing by running the old version of rubygems. The error is probably the mongrel gem developers error (I think).

In any case, if you just want to run your application using mongrel, do it like this. If you insist on having the latest version of rubygems, you can simply launch the application with

 script/server webrick 

But I found that webrick is a bit slower, so I prefer mongrel. If anyone has a better solution to this problem, let me know.

+1
source

I came across the same error. The fix is ​​to add the mongrel bin directory to $ LOAD_PATH. Other posts describe how to do this by modifying the source code, but since I use the source code for other developers, I prefer to set the RUBYLIB environment variable instead.

 $ export RUBYLIB=/Users/edwingo/.rvm/gems/ ruby-1.8.7-p302@junction /gems/mongrel-1.1.5/bin 

This causes the runtime of the MRI rubies to be added to $ LOAD_PATH.

Detailed explanation: MRI cannot find "mongrel_rails" because it is not on $ LOAD_PATH. I use RVM, and when I installed mongrel in the gemset, for some reason $ LOAD_PATH does not contain the corresponding bin directory where mongrel_rails lives. When not using RVM and after installing mongrel in the system gems, the bin directory appears in $ LOAD_PATH, so it all works.

+1
source

Source: https://habr.com/ru/post/1342748/


All Articles