使用Rails3和Ruby 1.9.2运行Mongrel时出现LoadError怎么回事?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (45)

当我运行我的代码时,我得到了这个:

C:\Ruby192\shovell>mongrel_rails start  
** Starting Mongrel listening at 0.0.0.0:3000  
** Starting Rails with development environment...   C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0.rc.6/lib/bundler/runtime.rb:27:in
'block in setup': You have already activated mongrel 1.2.
0.pre2, but your Gemfile requires mongrel 1.1.5. Consider using bundle exec. (Gem::LoadError)  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0.rc.6/lib/bundler/spec_set.rb:12:in
'block in each'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0.rc.6/lib/bundler/spec_set.rb:12:in
'each'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0.rc.6/lib/bundler/spec_set.rb:12:in
'each'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0.rc.6/lib/bundler/runtime.rb:17:in
'setup'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.0.rc.6/lib/bundler.rb:100:in
'setup'  
from C:/Ruby192/shovell/config/boot.rb:8:in '<top (required)>'  
from <internal:lib/rubygems/custom_require>:29:in 'require'  
from <internal:lib/rubygems/custom_require>:29:in 'require'  
from C:/Ruby192/shovell/config/application.rb:1:in '<top (required)>'  
from <internal:lib/rubygems/custom_require>:29:in 'require'  
from <internal:lib/rubygems/custom_require>:29:in 'require'  
from C:/Ruby192/shovell/config/environment.rb:2:in '<top (required)>'  
from <internal:lib/rubygems/custom_require>:29:in 'require'  
from <internal:lib/rubygems/custom_require>:29:in 'require'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/rails.rb:147:in
'rails'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:116:in
'block (2 levels) in run'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:149:in
'call'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:149:in
'listener'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:102:in
'block in run'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:50:in
'call'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:50:in
'initialize'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:86:in
'new'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:86:in
'run'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/command.rb:210:in
'run'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:282:in
'<top (required)>'  
from C:/Ruby192/bin/mongrel_rails:19:in 'load'  
from C:/Ruby192/bin/mongrel_rails:19:in '<main>'` 

提问于
用户回答回答于

我觉得是你的插件版本有问题。

gem 'mongrel', '>= 1.2.0.pre2'

第二个参数告诉Bundler需要一个等于或大于1.2.0.pre2的版本,在使用Ruby1.9.2时必须使用这个版本。

Bundler页面提供了关于如何使用Gemfile的很好的参考:http://gembundler.com/gifile.html

用户回答回答于

我运行了gem安装‘Dispatcher’,并在我的应用程序的Gemfile中添加了gem‘Dispatcher’。那一切都很好。

从我与ruby的体验来看,每次我都有一个“require -- no such file to load”的问题。这是因为我错过了一个特定的gem?

扫码关注云+社区