首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用Rails3和Ruby1.9.2运行Mongrel的LoadError

使用Rails3和Ruby1.9.2运行Mongrel的LoadError
EN

Stack Overflow用户
提问于 2010-10-26 10:42:53
回答 6查看 15.5K关注 0票数 17

我是个编程新手(以前只学过html/css/design),试图通过《简单的Rails 2》这本书开始学习RoR。然而,我想从最新版本的Ruby(1.9.2)和Rails (3)开始,所以我不得不在没有这本书的情况下完成所有的配置。我通过google和stackoverflow看了很多。当我运行rails server时,它会自动使用Webrick,但我想使用Mongrel。我通过gem install mongrel --pre安装了预发行版Mongrel,并删除了之前的版本。我读到为了让Mongrel使用rails server,我不得不将gem 'mongrel'添加到Gemfile中,但我不知道我应该将它添加到哪一个中(我尝试了几次,但没有任何改变)。因此,我决定通过git查看混合文档,并在运行mongrel_rails start时了解到以下内容:

代码语言:javascript
复制
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>'` 

我最好的猜测是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.是关键,但我还没能解决它。

我非常感谢任何人的帮助,这样我才能真正开始学习这门语言!

编辑:多亏了@duddle我才能解决上面的问题,但现在我有了另一个问题...我得到了这个错误:

代码语言:javascript
复制
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/activesupport-3.0.0.rc2/lib/active_support/dependencies.rb:239:in
'req uire': no such file to load -- dispatcher (LoadError)  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.rc2/lib/active_support/dependencies.rb:239:in 'block in require'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.rc2/lib/active_support/dependencies.rb:225:in 'block in load_dependency'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.rc2/lib/active_support/dependencies.rb:591:in 'new_constants_in'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.rc2/lib/active_support/dependencies.rb:225:in 'load_dependency'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.rc2/lib/active_support/dependencies.rb:239:in 'require'  
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/rails.rb:148: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>

在这一点上,我最好的猜测(1am...very疲劳)是我丢失了一个文件,或者没有命名,因为它应该be..maybe我需要在我的Gemfile..maybe中使用:require操作,我只需要在它上面睡觉。哈哈。

再次感谢@duddle帮我度过了第一个错误!如有更多帮助,我们将不胜感激!

EN

回答 6

Stack Overflow用户

回答已采纳

发布于 2010-10-26 14:11:47

您已经激活了Mongrel1.2。0.pre2,但是你的Gemfile需要mongrel 1.1.5。考虑使用捆绑包exec。是关键,但我一直没能解决它。

你就快到了!

代码语言:javascript
复制
gem 'mongrel', '>= 1.2.0.pre2'

第二个参数告诉bundler要求版本大于或等于1.2.0.pre2,在使用Ruby 1.9.2时必须使用该版本。

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

票数 32
EN

Stack Overflow用户

发布于 2010-12-07 04:28:34

以防你没弄明白。

我运行了gem install 'dispatcher‘,并在我的应用程序的Gemfile中添加了gem 'dispatcher’。然后一切都好了。

从我使用ruby的小经验来看,每次我都遇到“需要--没有这样的文件要加载”的问题。这是因为我错过了一个特定的宝石。

哈..。

票数 5
EN

Stack Overflow用户

发布于 2011-02-01 20:43:53

将下面这一行添加到gem文件:

代码语言:javascript
复制
gem 'mongrel', '>= 1.2.0.pre2'

在命令提示符下:

运行bundle install

使用以下命令启动mongrel:

代码语言:javascript
复制
rails server
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4020309

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档