使用 Rails 2.3.5 绕过机架版本错误 [英] Bypassing rack version error using Rails 2.3.5

查看:13
本文介绍了使用 Rails 2.3.5 绕过机架版本错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在 Dreamhost 上尝试运行 Rails 2.3.5 应用程序.

情况是这样的,Dreamhost 的服务器安装了 Rails 2.2.2.当然,我不能更新共享主机的 rails 版本,所以我在 vendor.js 中冻结了我的 Rails.Rails 2.3.5 需要 rack v1.0.1 gem.Dreamhost 使用 rack v1.0.0 gem.所以当我尝试定义时:

config.gem "机架", :version =>1.0.1"

我明白了:

无法为 [] 激活 rack (~> 1.0.1, runtime),已经为 [] 激活 rack-1.0.0

所以我真正需要做的是绕过我的应用程序使用 1.0.1 的请求,并使用 Dreamhost 的 1.0.0.有谁知道如何配置这个?甚至可能吗?感谢您的帮助.

解决方案

您几乎总是希望将应用程序所依赖的 gem 解压缩到 vendor 文件夹中.你可以用这个 rake 命令来做到这一点:

rake gems:unpack:dependencies

这将在您的应用程序的根文件夹下创建一个文件夹 vendor/gems,并将您使用 config.gem 命令声明的所有 gem 解压缩到其中.p>

这不仅可以解决您的 rack 版本不匹配的问题,还可以确保您在生产中使用与在开发中使用的完全相同版本的 gem,这可以防止许多潜在的以后头疼.

I'm currently on Dreamhost attempting to run a Rails 2.3.5 app.

Here is the situation, Dreamhost's servers have Rails 2.2.2 installed. Of course, I can't update a shared host's rails version, so I froze my Rails in vendor. Rails 2.3.5 requires the rack v1.0.1 gem. Dreamhost uses the rack v1.0.0 gem. So when I try to define:

config.gem "rack", :version => "1.0.1"

I get:

can't activate rack (~> 1.0.1, runtime) for [], already activated rack-1.0.0 for []

So what I really need to do is bypass my app's request to use 1.0.1, and use Dreamhost's 1.0.0. Does anyone know how to configure this? Is it even possible? Thanks for the help.

解决方案

You will almost always want to unpack the gems that your application depends on into the vendor folder. You can do that with this rake command:

rake gems:unpack:dependencies

This will create a folder vendor/gems under your application's root folder and unpack all of the gems that you declared with the config.gem command into it.

This will not only solve your problem with mismatching rack versions, but also make sure that you are using the exact same versions of gems in production as you are using in development, which can prevent many potential headaches in the future.

这篇关于使用 Rails 2.3.5 绕过机架版本错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆