如何确保 Ruby 使用我的 Rails 应用程序中提供的 Rack gem?
我的 Rails 2.3.x 应用程序失败,因为它使用了错误版本的 Rack(有 bug< /a>)。我的系统上有两个版本的 Rack,一个是供应商版本(正确的版本),另一个是通过 apt-get 安装的系统版本。
为什么它使用了错误的版本?这让我特别困惑,因为供应的版本在调用堆栈的早期被正确使用。我怎样才能让它使用正确的版本?
以下是应用程序失败时我得到的堆栈跟踪的摘录:
/usr/lib/ruby/vendor_ruby/rack/utils.rb:202:in `set_cookie_header!'
/home/alaveteli/vendor/gems/rack-1.1.0/lib/rack/response.rb:57:in `set_cookie'
/home/alaveteli/vendor/rails/actionpack/lib/action_controller/response.rb:181:in `set_cookie'
请注意,第 2 行使用的是供应商的机架,但第 1 行使用的是系统机架。 (response.rb
的第 57 行从 Rack 调用一个模块,因此:Utils.set_cookie_header!(header, key, value)
。)
我的 $LOAD_PATH 正如我所认为的那样,供应的宝石先于系统宝石。
是的,我计划尽快迁移到使用 Bundler。
My Rails 2.3.x application is failing, because it's using the wrong version of Rack (one with a bug). There are two versions of Rack on my system, a vendored one (the right version) and a system one, installed via apt-get
.
Why is it using the wrong version? This is particularly puzzling me because the vendored version is being correctly used earlier in the call stack. And how I can make it use the right version?
Here's an excerpt from the stack trace I'm getting when the application fails:
/usr/lib/ruby/vendor_ruby/rack/utils.rb:202:in `set_cookie_header!'
/home/alaveteli/vendor/gems/rack-1.1.0/lib/rack/response.rb:57:in `set_cookie'
/home/alaveteli/vendor/rails/actionpack/lib/action_controller/response.rb:181:in `set_cookie'
Note that line 2 is using the vendored Rack, but line 1 is using the system Rack. (Line 57 of response.rb
calls a module from Rack, thus: Utils.set_cookie_header!(header, key, value)
.)
My $LOAD_PATH
is as I believe it should be, with the vendored gems coming before the system ones.
Yes, I am planning to migrate to using Bundler soonish.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用 rbenv 和 ruby-build。这是一个健全的 ruby 版本管理系统(与疯狂的 rvm 不同)。每个文件夹都会有一个 ruby 版本及其所有宝石。当我遇到 alaveteli 问题时,我通常会在开发邮件列表上询问他们。我经营罗马尼亚的 alaveteli。
Try using rbenv and ruby-build. It's a sane ruby version management system (unlike rvm which is insane). You get a ruby version per folder and all it's gems. When I have alaveteli issues, I usually ask them on the dev mailing list. I run the Romanian alaveteli.