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:http://ascarter.net/2011/09/25/现代 ruby-development.html 这篇关于如何在 rbenv 中使用多个 Rails 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-16 16:25