![](/img/trans.png)
[英]Rails mongrel with RVM fails to startup - mongrel_rails (MissingSourceFile)
[英]Rails 2.x mongrel won't start after upgrading to rails 3. — mongrel_rails (MissingSourceFile)
将我的Rails安装升级到OS X上的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
→新鲜应用有同样的问题。
gem -v
:1.6.1 我已经在“ - mongrel_rails(MissingSourceFile)”中阅读了每一个Google结果; 没有多少。
这里的任何人都可以告诉我如何进行调试吗? 谢谢!
我现在尝试安装旧版本的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/dependencies.rb
归admin / root所有,所以应该没问题吧?
这可能是active_support的问题!?
这是来自dependencies.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
显示它,那么问题是什么?
我有同样的问题,找到了原因。
发生这种情况是因为当您需要“any_gem”时,新版本的RubyGems(1.6.2)不会将'any_gem / bin'添加到ruby加载路径($ LOAD_PATH)。
例如,在RubyGems版本= 1.4.1中,这可以正常工作。 在我需要'mongrel'后,我可以在加载路径中看到下一个:
对于新版本(1.6.2),我只能看到:
这就是为什么红宝石找不到'mongrel_rails'。
您需要在加载路径中添加“/ usr / bin”。 也许有些东西破了吗?
解决它的最佳方法是添加:
$:.push("/usr/bin/")
在它休息之前的某个地方。 如果你没有,可能在config / preinitializer.rb文件中单独使用。
好的,这是一个答案。 我得到了mongrel引导...但它很hacky,并没有解决真正的问题...但至少现在我可以回到这个项目的工作。
这就是我的所作所为......是的。这是HACKY。
我编辑了抛出错误的文件... dependencies.rb
我添加了一个钩子来调出mongrel rails的特定路径,如果那是它试图加载的文件。
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
再说一次,我真的想在这里解决潜在的问题......但这至少让我启动了。
我肯定会考虑使用RVM在本地同时运行多个gem版本。 当我试图运行多个版本时,我遇到了很多怪癖,就像你使用sudo gem installs一样。
现在它就像rvm ree@my_app_1
一样简单,并在那里安装完全独立的宝石,然后切换到另一个应用程序并使用rvm ree@my_app_2
ree是我安装ruby企业版的别名,你可以用ruby 1.9,1.8.x等轻松完成。
在我的每个应用程序的根目录中,我都有一个简单读取的.rvmrc
文件:
rvm ree@my_app --create
因此,每次切换到该目录时,gemset都会自动交换给我。
我不知道有Rails 3 mongrel支持。
大多数人都使用Thin(你可以通过在你的Gemfile
指定Gemfile
gem 'thin'
来启用它,然后启动rails server thin
/ Webrick这些天。
如果这是托管,那么有nginx和Passenger会对此有所帮助。
我遇到了同样的问题 - 通过从项目目录(而不是“脚本/服务器”)运行“mongrel_rails”来获取我的应用程序。
这是您能够找到mongrel_rails(MissingSourceFile)错误的最佳答案的线程。 我只想在这里总结一下如何使用此线程中的内容解决问题。
我可以弄清楚如何做的最简单的解决方案是通过键入来降级RubyGems
(sudo) gem update --system 1.4.1
这让我运行旧的2.1.0应用程序(感谢Max Shytikov),但是通过运行旧版本的rubygems,我可能会遗漏很多错误修正。 这个错误可能是杂种宝石开发者的错误(我猜)。
无论如何,如果您只是想使用mongrel运行您的应用程序,请执行此操作。 如果你坚持使用最新版本的rubygems,你可以运行你的应用程序
script/server webrick
但我发现webrick有点慢,所以我更喜欢杂种。 如果有人为这个问题找到了更好的解决方案,请告诉我。
我遇到了同样的错误。 修复是将mongrel“bin”目录添加到$ LOAD_PATH。 其他帖子描述了如何通过修改源代码来实现,但由于我与其他开发人员共享源代码,我更喜欢设置RUBYLIB环境变量。
$ export RUBYLIB=/Users/edwingo/.rvm/gems/ruby-1.8.7-p302@junction/gems/mongrel-1.1.5/bin
这会导致MRI ruby运行时将其添加到$ LOAD_PATH。
详细解释:MRI无法找到'mongrel_rails',因为它不在$ LOAD_PATH上。 我正在使用RVM,当我将mongrel安装到gemset时,由于某种原因,$ LOAD_PATH不包含'mongrel_rails'所在的相应“bin”目录。 当不使用RVM并在将mongrel安装到系统gem中之后,“bin”目录确实出现在$ LOAD_PATH上,因此一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.