升级到 Rails 3 后,Rails 2.x mongrel 将无法启动。 -- mongrel_rails (MissingSourceFile)
在 OS X 上将 Rails 安装升级到 Rails 3 后,我在使用 Mongrel 运行 Rails 2.x 开发站点时遇到了问题。 WEBrick 似乎可以工作,但我真的希望有 Mongrel 的良好输出来进行调试。
运行 $ script/server
后,我得到:
/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'
到目前为止,这是我尝试过的:
$ 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
→ 成功,但没有标准输出
$ which mongrel_rails
→ /usr/bin/mongrel_rails
$ rails _2.0.2_ test
→ 新的应用程序也有同样的问题。
- 操作系统:OS X.6.x
- Rails:3.0.5(Rails 2.x 应用程序有问题)
gem -v
:1.6.1- Mongrel:mongrel (1.1.5)
我已经阅读了所有内容谷歌搜索结果“-- mongrel_rails (MissingSourceFile)”;没有很多。
这里有人能告诉我如何继续调试吗?谢谢!
更新:
我现在尝试安装旧版本的 gem 并在 Rails 2.x 站点的 config/environment.rb 文件中指定这些版本。我尝试过 1.1.5、1.1.4 和 1.2.0pre。
这些都没有丝毫区别。
由于可执行文件位于 usr/bin 中,我想知道这是否是我的 Rails 3 安装中出现的文件所有权问题,以及其中一个文件在运行时是否没有获取我的路径?
/Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependency.rb
属于 admin / root,所以应该没问题,对吧?
难道是active_support的问题!?
这是来自 dependency.rb
的代码,它抛出了错误:
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
...
这是一个文件未找到的错误,所以它不会查找我知道文件所在的位置...... 在命令行上运行 mongrel_rails 可以工作...... 其中 mongrel_rails 在 usr/bin
中显示它, 那么问题出在哪里呢?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
我也遇到了同样的问题并找到了原因。
发生这种情况是因为当您需要“any_gem”时,新版本的 RubyGems(1.6.2) 不会将“any_gem/bin”添加到 ruby 加载路径 ($LOAD_PATH)。
例如,在 RubyGems 版本 = 1.4.1 中,这可以正常工作。在我需要“mongrel”之后,我可以在接下来的加载路径中看到:
使用新版本(1.6.2)我只能看到:
这就是 ruby 的原因找不到“mongrel_rails”。
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:
With new version (1.6.2) I can see only:
That's why ruby cannot find 'mongrel_rails'.
您需要将“/usr/bin”添加到加载路径中。也许里面有什么东西坏了?
修复它的最好方法是
在它损坏之前的某个地方 添加:如果您没有的话,可能会在 config/preinitializer.rb 文件中单独存在。
You need to add "/usr/bin" to your load path. Perhaps something broke in it?
The best way to fix it is to add:
Somewhere before it breaks. Probably by itself in a config/preinitializer.rb file if you don't have one.
好的,这是一个答案。我启动了杂种...但它很老套,并且不能解决真正的问题...但至少现在我可以重新开始这个项目的工作。
这就是我所做的...是的..这很HACKY。
我编辑了抛出错误的文件...dependency.rb
我添加了一个钩子来调出 mongrel Rails 的特定路径(如果这是它试图加载的文件)。
再说一遍,我真的很想解决这里的根本问题......但这至少让我可以启动。
OK, here's ONE answer. I got mongrel to boot...but it's hacky, and doesn't solve the real problem...but at least for NOW I can get back to work on this project.
Here's what I did...YES..it's HACKY.
I edited the file throwing the error...dependencies.rb
I added a hook to call out the specific path to mongrel rails if that was the file it was trying to load.
Again, I would really like to fix the underlying problem here...but this at least let me boot up.
我肯定会考虑使用 RVM 在本地同时运行多个 gem 版本。当我尝试运行多个版本时,我遇到了很多怪癖,就像您使用 sudo gem 安装所有内容一样。
现在就像
rvm ree@my_app_1
一样简单,在那里安装完全独立的 gem,然后切换到不同的应用程序并使用rvm ree@my_app_2
ree 是我安装的别名对于 ruby 企业版,您可以使用 ruby 1.9、1.8.x 等轻松地完成此操作。
在我的每个应用程序的根目录中,我都有一个
.rvmrc
文件,其内容如下:我切换到该目录,宝石集会自动为我交换。
I would definitely look in to using RVM for running multiple gem versions simultaneously locally. I ran into a lot of quirks when I was attempting to run multiple versions like you are with sudo gem installs of everything.
Now it's as simple as
rvm ree@my_app_1
, and installing completely separate gems there, then switching to a different app and usingrvm ree@my_app_2
ree is an alias for my install of ruby enterprise version, you could just as easily do it with ruby 1.9, 1.8.x, etc.
In each of my application's root directories I have a
.rvmrc
file that reads simply:So that every time I switch to that directory, the gemset is automatically swapped for me.
我不知道有 Rails 3 混合支持。
大多数人都使用 Thin(您可以通过在
Gemfile
中指定gem 'thin'
来启用它,然后启动rails server Thin
/ Webrick 这些天。如果这是用于托管的,然后有 nginx 和 Passenger 来帮助解决这个问题。
I wasn't aware there was Rails 3 mongrel support.
Most people use Thin (you can enable it by specifying
gem 'thin'
in yourGemfile
then launchingrails server thin
/ Webrick these days.If this is for hosting then there's nginx and Passenger that'll help with that.
我遇到了同样的问题 - 通过从项目目录(而不是“script/server”)运行“mongrel_rails”来启动我的应用程序。
I ran into the same problem -- got my app going by running "mongrel_rails" from the project directory (instead of "script/server").
您可以在该线程中找到 mongrel_rails (MissingSourceFile) 错误的最佳答案。我只想在这里总结一下我如何使用该线程中的内容解决问题。
我能想到的最简单的解决方案是通过输入降级 RubyGems
这让我可以运行旧的 2.1.0 应用程序(感谢 Max Shytikov),但是运行旧版本的 RubyGems 可能会缺少很多错误修复红宝石。该错误可能是杂种宝石开发人员的错误(我猜)。
无论如何,如果您只想使用 mongrel 运行您的应用程序,请这样做。如果您坚持使用最新版本的 rubygems,您可以使用以下命令运行您的应用程序
,但我发现 webrick 速度要慢一些,所以我更喜欢 mongrel。如果有人对这个问题有更好的解决方案,请告诉我。
This is the thread where you are able to find the best answer to the mongrel_rails (MissingSourceFile) error. I just want to conclude here how I solved the problem, using stuff in this thread.
The simplest solution I could figure out how to do was to downgrade RubyGems by typing
This lets me run the old 2.1.0 app (thanks Max Shytikov), but there's probably a lot of bugfixes that I'm missing by running the old version of rubygems. The error is probably a blunder by the mongrel gem developers (I guess).
Anyway if you just want to run your app using mongrel do it like this. If you insist on having the newest version of rubygems, you can just run your app with
But I've found that webrick is a fair bit slower, so I prefer mongrel. If anyone has got a better solution for this problem, please let me know.
我遇到了同样的错误。修复方法是将 mongrel“bin”目录添加到 $LOAD_PATH。其他帖子描述了如何通过修改源代码来完成此操作,但由于我与其他开发人员共享源代码,所以我更喜欢设置 RUBYLIB 环境变量。
这会导致 MRI ruby 运行时将其添加到 $LOAD_PATH 之前。
详细解释:MRI 无法找到“mongrel_rails”,因为它不在 $LOAD_PATH 上。我正在使用 RVM,当我将 mongrel 安装到 gemset 中时,由于某种原因,$LOAD_PATH 不包含“mongrel_rails”所在的相应“bin”目录。当不使用 RVM 并将 mongrel 安装到系统 gem 后,“bin”目录确实出现在 $LOAD_PATH 上,因此一切正常。
I ran into the same error. The fix is to add the mongrel "bin" directory to the $LOAD_PATH. Other posts describe how to do it by modifying source code, but since I share source code with other developers, I prefer to set the RUBYLIB environment variable instead.
This causes the MRI ruby runtime to prepend that to the $LOAD_PATH.
Detailed explanation: MRI is unable to find 'mongrel_rails' because it is not on the $LOAD_PATH. I am using RVM and when I installed mongrel into a gemset, for some reason the $LOAD_PATH does not include the corresponding "bin" directory where 'mongrel_rails' lives. When not using RVM and after installing mongrel into the system gems, the "bin" directory does appear on the $LOAD_PATH so it all works.