使用 Rails3 和 Ruby 1.9.2 运行 Mongrel 时出现 LoadError

发布于 2024-09-28 20:55:37 字数 6181 浏览 2 评论 0原文

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

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':您已经激活了 mongrel 1.2。 0.pre2,但您的 Gemfile 需要 mongrel 1.1.5。考虑使用bundle exec。是关键,但我一直无法解决它。

我将不胜感激任何帮助,以便我能够继续实际学习 语言!

编辑:感谢@duddle,我能够解决上述问题,但现在我有另一个问题...我收到此错误:

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>

我此时的最佳猜测(凌晨 1 点...非常累)是我丢失了一个文件或者某些东西没有按应有的名称命名。也许我需要在 Gemfile 中使用 :require 操作。也许我只需要睡觉。哈。

再次感谢 @duddle 让我克服了第一个错误!任何更多的帮助将不胜感激!

I am new to programming (previously only did html/css/design) trying to start learning RoR via the book Simply Rails 2. However I want to start with the most recent versions of Ruby(1.9.2) and Rails (3) so I am forced to get everything configured without the book. I have looked a lot via google and on stackoverflow. When I run rails server it automatically uses Webrick, but I want to be using Mongrel. I installed the prerelease Mongrel via gem install mongrel --pre and removed the previous version. I read that in order to get Mongrel to work with rails server I had to add gem 'mongrel' to the Gemfile, but I do not know which one I should be adding it to (I tried several but nothing changed). So I decided to look at mongrel documentation via git and learned about mongrel_rails start when I run that I get this:

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>'` 

My best guess is that
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.
is the key but I have not been able to solve it.

I would appreciate any help so that I can get on to actually learning
the language!

EDIT: I was able to get past the above issue thanks to @duddle but now I have another issue...I am getting this error:

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>

My best guess at this point (1am...very tired) is that I am missing a file or something is not named as it should be..maybe i need to use the :require action in my Gemfile..maybe I just need to sleep on it. Ha.

Again, thanks a ton @duddle for getting me past the first error! Any more help is greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

熟人话多 2024-10-05 20:55:37

您已经激活了 mongrel 1.2。 0.pre2,但您的 Gemfile 需要 mongrel 1.1.5。考虑使用捆绑执行。是关键,但我一直没能解决。

你就快到了!

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

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

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

You have already activated mongrel 1.2. 0.pre2, but your Gemfile requires mongrel 1.1.5. Consider using bundle exec. is the key but I have not been able to solve it.

You were almost there!

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

The second parameter tells bundler to require a version equal to or greater than 1.2.0.pre2, which you have to use when using Ruby 1.9.2.

The Bundler page provides a nice reference on how to use the Gemfile: http://gembundler.com/gemfile.html

止于盛夏 2024-10-05 20:55:37

以防万一你没弄清楚。

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

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

呃……

Just in case you didn't figure it out.

I ran gem install 'dispatcher' and added gem 'dispatcher' in the Gemfile of my app.
Then everything was fine.

From the small experience I have with ruby, everytime I have a "require -- no such file to load" problem. It is because I am missing a specific gem.

Hth...

衣神在巴黎 2024-10-05 20:55:37

将此行添加到您的 gem 文件中:

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

在命令提示符处:

运行 bundle install

使用以下命令启动 mongrel:

rails server

add this line to your gem file:

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

at the command prompt:

run bundle install

start mongrel using this command:

rails server
爱本泡沫多脆弱 2024-10-05 20:55:37

嘿,我遇到了这个问题,解决方案非常简单:

只需添加 gem 'dispatch'

;-)

Hey, I ran into that problem, the solution was quite simple:

Just add the gem 'dispatch'

;-)

苏辞 2024-10-05 20:55:37

mongrel gem 与 Ruby 1.9.2 不兼容;你必须使用 gem 'sho-mongrel' 来代替它。

The mongrel gem isn’t compatible with Ruby 1.9.2; you’ll have to use gem 'sho-mongrel' in its place.

我做我的改变 2024-10-05 20:55:37

尝试使用以下命令安装它:

gem install mongrel --pre

它对我来说完美!

Try to install it using:

gem install mongrel --pre

It worked for me perfect!!!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文