如何在 rbenv 中使用多个 Rails 版本?

编程入门 行业动态 更新时间:2024-10-27 15:23:59
本文介绍了如何在 rbenv 中使用多个 Rails 版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否可以使用 rbenv 使用多个版本的 rails(例如 2.3 和 3.1)?这对于 rvm 中的 gemsets 很容易,但我想知道现在我已经切换到 rbenv 的最佳方法是什么(另外,我正在寻找一种没有 rbenv-gemset 的方法).

Is it possible to use multiple versions of rails using rbenv (e.g. 2.3 and 3.1)? This was easy with gemsets in rvm, but I'm wondering what the best way is to do it now that I've switched to rbenv (also, I'm looking for a way to do it without rbenv-gemset).

推荐答案

不确定你是否得到了答案,但我想我会提供我所做的并且它似乎有效.

not sure if you got an answer to this, but I thought I'd offer what I did and it seemed to work.

因此,一旦您安装了 rbenv,并使用它来安装特定的 ruby​​ 版本,您就可以为该 ruby​​ 安装多个版本的 rails.

So once you get rbenv installed, and you use it to install a specific ruby version, you can install multiple versions of rails to for that ruby.

步骤 1. 为每个 ruby​​ 版本安装您想要的任何版本的 rails

% RBENV_VERSION=1.9.2-p290 rbenv exec gem install rails --version 3.0.11

通过在命令行中使用RBENV_VERSION=1.9.2-p290"前缀,您可以指定应该关注哪个 ruby​​ rbenv.

By using the "RBENV_VERSION=1.9.2-p290" prefix in your command line, you're specifying which ruby rbenv should be concerned with.

然后使用rbenv exec"命令,您可以安装rails.只需使用示例中的版本标志来指定您想要的版本.不确定您是否可以一次性安装多个版本,但我只是根据需要多次运行此命令来安装我想要的每个版本.

Then following that with the "rbenv exec" command, you can install rails. Just use the version flag as in the example to specify which version you want. Not sure if you can install multiple versions in one shot, but I just run this command as many times as needed to install each version I want.

注意:这一切都将在您的 rbenv 目录中进行管理,因此它非常安全且包含在内.

步骤 2. 通过指定所需的 rails 版本构建新的 rails 项目.

% RBENV_VERSION=1.9.2-p290 rbenv exec rails _3.0.11_ new my_project

第 3 步.不要忘记进入该项目并设置本地 rbenv ruby​​ 版本.

% cd my_project % rbenv local 1.9.2-p290

现在,如果您想删除此项目,只需照常删除即可.

Now if you want to delete this project, just delete it as normal.

如果您想从 rbenv gems 中删除/管理 rails 版本,您可以使用常规 gem 命令,只需在命令行前加上:

If you want to delete / manage a rails version from rbenv gems, you can use regular gem commands, just prefix your command line with:

% RBENV_VERSION=1.9.2-p290 rbenv exec gem {some command}

当然,您可以非常轻松地删除在 rbenv 中管理的完整 ruby​​ 版本及其所有垫片等.我喜欢一切都是独立的.

And of course, you can delete a complete ruby version and all its shims, etc that are managed within rbenv pretty easily. I like how self contained everything is.

希望这会有所帮助.

作为参考,这是对至少其中一些内容的一个很好的介绍:

For reference, this is a pretty good walk through of at least some of this stuff:

ascarter/2011/09/25/现代 ruby​​-development.html

更多推荐

如何在 rbenv 中使用多个 Rails 版本?

本文发布于:2023-10-29 02:47:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538504.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   版本   如何在   rbenv   Rails

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!