Rails - 使用 Thin 时捆绑器错误

发布于 2024-09-29 03:29:33 字数 2715 浏览 4 评论 0原文

我开始使用捆绑器,但在使用它时遇到了一些问题。我有以下 gemfile:

source "http://rubygems.org"
gem "rack", "~>1.1"
gem 'pg','>= 0.8.0'
gem 'rails','2.3.8'
gem 'authlogic','2.1.3'
gem 'ajaxful_rating','2.2.3'
gem 'will_paginate','2.3.12'
gem 'right_aws','1.10.0'
gem 'aws-s3','0.6.2'
gem 'declarative_authorization','0.4.1'
gem 'timeline_fu','0.3.0'
gem 'friendly_id','>= 3.1'

请注意,我明确表示要使用机架 1.1 (1.1.0)。

当我使用 Thin 运行时,出现以下错误(Webrick 工作正常):

thin start
>> Using rails adapter
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/runtime.rb:27:in `setup': You have already activated rack 1.2.1, but your Gemfile requires rack 1.1.0. Consider using bundle exec. (Gem::LoadError)
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/spec_set.rb:12:in `each'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/spec_set.rb:12:in `each'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/runtime.rb:17:in `setup'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler.rb:100:in `setup'
 from /home/vmplanet/Documents/maga/config/../config/preinitializer.rb:16
 from /home/vmplanet/Documents/maga/config/boot.rb:28:in `load'
 from /home/vmplanet/Documents/maga/config/boot.rb:28:in `preinitialize'
 from /home/vmplanet/Documents/maga/config/boot.rb:10:in `boot!'
 from /home/vmplanet/Documents/maga/config/boot.rb:126
 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
 from /home/vmplanet/Documents/maga/config/environment.rb:7
 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
 from /home/vmplanet/.gem/ruby/1.8/gems/thin-1.2.7/lib/rack/adapter/rails.rb:42:in `load_application'
 from /home/vmplanet/.gem/ruby/1.8/gems/thin-1.2.7/lib/rack/adapter/rails.rb:23:in `initialize'
 from /home/vmplanet/.gem/ruby/1.8/gems/thin-1.2.7/lib/rack/adapter/loader.rb:48:in `new'
 from /home/vmplanet/.gem/ruby/1.8/gems/thin-1.2.7/lib/rack/adapter/loader.rb:48:in `for'
 from /home/vmplanet/.gem/ruby/1.8/gems/thin-1.2.7/lib/thin/controllers/controller.rb:163:in `load_adapter'
 from /home/vmplanet/.gem/ruby/1.8/gems/thin-1.2.7/lib/thin/controllers/controller.rb:67:in `start'
 from /home/vmplanet/.gem/ruby/1.8/gems/thin-1.2.7/lib/thin/runner.rb:177:in `send'
 from /home/vmplanet/.gem/ruby/1.8/gems/thin-1.2.7/lib/thin/runner.rb:177:in `run_command'
 from /home/vmplanet/.gem/ruby/1.8/gems/thin-1.2.7/lib/thin/runner.rb:143:in `run!'

所以基本上它是在抱怨我使用的是rack 1.2.1(事实并非如此,我想不出任何使用它的东西)。

有什么想法吗?

I started using bundler and have some problems getting it working. I have the following gemfile:

source "http://rubygems.org"
gem "rack", "~>1.1"
gem 'pg','>= 0.8.0'
gem 'rails','2.3.8'
gem 'authlogic','2.1.3'
gem 'ajaxful_rating','2.2.3'
gem 'will_paginate','2.3.12'
gem 'right_aws','1.10.0'
gem 'aws-s3','0.6.2'
gem 'declarative_authorization','0.4.1'
gem 'timeline_fu','0.3.0'
gem 'friendly_id','>= 3.1'

Notice that I specificy that I want to use rack 1.1 (1.1.0).

I get the following error when I run with thin (Webrick works fine):

thin start
>> Using rails adapter
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/runtime.rb:27:in `setup': You have already activated rack 1.2.1, but your Gemfile requires rack 1.1.0. Consider using bundle exec. (Gem::LoadError)
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/spec_set.rb:12:in `each'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/spec_set.rb:12:in `each'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/runtime.rb:17:in `setup'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler.rb:100:in `setup'
 from /home/vmplanet/Documents/maga/config/../config/preinitializer.rb:16
 from /home/vmplanet/Documents/maga/config/boot.rb:28:in `load'
 from /home/vmplanet/Documents/maga/config/boot.rb:28:in `preinitialize'
 from /home/vmplanet/Documents/maga/config/boot.rb:10:in `boot!'
 from /home/vmplanet/Documents/maga/config/boot.rb:126
 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
 from /home/vmplanet/Documents/maga/config/environment.rb:7
 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
 from /home/vmplanet/.gem/ruby/1.8/gems/thin-1.2.7/lib/rack/adapter/rails.rb:42:in `load_application'
 from /home/vmplanet/.gem/ruby/1.8/gems/thin-1.2.7/lib/rack/adapter/rails.rb:23:in `initialize'
 from /home/vmplanet/.gem/ruby/1.8/gems/thin-1.2.7/lib/rack/adapter/loader.rb:48:in `new'
 from /home/vmplanet/.gem/ruby/1.8/gems/thin-1.2.7/lib/rack/adapter/loader.rb:48:in `for'
 from /home/vmplanet/.gem/ruby/1.8/gems/thin-1.2.7/lib/thin/controllers/controller.rb:163:in `load_adapter'
 from /home/vmplanet/.gem/ruby/1.8/gems/thin-1.2.7/lib/thin/controllers/controller.rb:67:in `start'
 from /home/vmplanet/.gem/ruby/1.8/gems/thin-1.2.7/lib/thin/runner.rb:177:in `send'
 from /home/vmplanet/.gem/ruby/1.8/gems/thin-1.2.7/lib/thin/runner.rb:177:in `run_command'
 from /home/vmplanet/.gem/ruby/1.8/gems/thin-1.2.7/lib/thin/runner.rb:143:in `run!'

So basically it is complaining that I am using rack 1.2.1 (which is not the case, I can't think of anything using it).

Any thoughts?

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

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

发布评论

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

评论(4

怪我闹别瞎闹 2024-10-06 03:29:33

Thin 本身取决于 Rack。由于 Thin 会在加载应用程序之前自行加载,因此当捆绑程序首次进入时,最新版本的 Rack 已经被加载。

您必须强制使用正确版本的 Rack to Thin。理论上,您的系统 gem 中只能有 Rack 1.1.0,但这很难维护或移植。错误消息已经包含了答案;使用bundle exec

bundle exec thin start

Thin itself depends on Rack. And because Thin will load itself before it loads your application, the most recent version of Rack will already be loaded when bundler first enters the picture.

You have to force the correct version of Rack to Thin. In theory you could only have Rack 1.1.0 in your system gems, but that's hardly maintainable or portable. The error message already contains the answer; use bundle exec.

bundle exec thin start
雨后咖啡店 2024-10-06 03:29:33

所以基本上它是在抱怨我正在使用rack 1.2.1(这是
事实并非如此,我想不出有什么可以使用它)。

我也这么想,但事实就是如此。 Rubygems 使用的是最新版本。 Bundler 允许您使用以下方法覆盖此默认值

bundle exec foo

当您将 gem 安装到系统时,Rubygems 会创建包装器
gem 提供的每个可执行文件。当你运行一个
无需捆绑执行即可从命令行执行,此包装器
调用 Rubygems,然后使用正常的 Rubygems 激活
调用 gem 可执行文件的机制。这在过去已经改变
几个月后,Rubygems 将调用最新版本的 gem
安装在您的系统中,即使您的 Gemfile.lock 指定了
不同的版本。此外,它将激活最新的
(兼容)已安装该 gem 依赖项的版本,即使
Gemfile.lock 中指定了不同的版本。 来源

So basically it is complaining that I am using rack 1.2.1 (which is
not the case, I can't think of anything using it).

I thought the same thing but it is the case. Rubygems is using the latest version. Bundler allows you to override this default by using

bundle exec foo

When you install a gem to the system, Rubygems creates wrappers for
every executable that the gem makes available. When you run an
executable from the command line without bundle exec, this wrapper
invokes Rubygems, which then uses the normal Rubygems activation
mechanism to invoke the gem’s executable. This has changed in the past
several months, but Rubygems will invoke the latest version of the gem
installed in your system, even if your Gemfile.lock specifies a
different version. In addition, it will activate the latest
(compatible) installed version of dependencies of that gem, even if a
different version is specified in your Gemfile.lock. source

您可以在heroku 网站上找到有关使用thin 的信息。他们还建议使用薄的。
http://devcenter.heroku.com/articles/rails3#webserver

You can find information on heroku's site about using thin. Also they are recommend using thin.
http://devcenter.heroku.com/articles/rails3#webserver

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