[英]How to change the version of bundler being used in rails?
When I run the following command, it gives me the available installed versions of bundler:当我运行以下命令时,它为我提供了可用的 bundler 安装版本:
command :命令:
gem list | grep "bundle"
output:输出:
bundler (1.11.2, 1.10.6, 1.10.4, 1.3.6, 1.3.0, 1.3.0.pre)
The current version of bundler I obtained was 1.11.2 using the following command:我使用以下命令获得的当前版本的 bundler 是 1.11.2:
bundler --version
I want to use version 1.3.6 How do I swap the current version of bundler with the available ones?我想使用版本 1.3.6 如何将当前版本的 bundler 与可用版本交换?
Normally during development Bundler is used from it's executable on your system, so I don't believe you can specify a specific version in your Gemfile, for example.通常在开发过程中,Bundler 在您系统上的可执行文件中使用,因此我不相信您可以在 Gemfile 中指定特定版本,例如。 (You might try it, though).
(不过,您可以尝试一下)。 However, you can install the version you like and force the shell/rubygems to use that version:
但是,您可以安装您喜欢的版本并强制 shell/rubygems 使用该版本:
$ gem install bundler -v 1.3.6
...
1 gem installed
$ bundle _1.3.6_ -v
Bundler version 1.3.6
To get my machine to use 1.3.6 by default I had to uninstall 1.11.2.为了让我的机器默认使用 1.3.6,我必须卸载 1.11.2。
Update: I tried specifying gem 'bundler', '~> 1.3'
in one of my projects and it worked, although the CLI for bundler still used the system default version.更新:我尝试在我的一个项目中指定
gem 'bundler', '~> 1.3'
并且它有效,尽管 bundler 的 CLI 仍然使用系统默认版本。
If you want to upgrade bundler 1 to 2 , then you should do the following:如果要将 bundler 1 升级到 2 ,则应执行以下操作:
1- The first step in upgrading to Bundler 2 is installing the Bundler 2 gem by running: 1- 升级到 Bundler 2 的第一步是通过运行以下命令安装 Bundler 2 gem:
gem install bundler
2- When Bundler 2 installed, Bundler will automatically switch between version 1 and version 2 based on your application's Gemfile.lock based on the BUNDLED WITH ((version))
in your Gemfile.lock 2- 安装 Bundler 2 后,Bundler 将根据您的应用程序的 Gemfile.lock 基于您的 Gemfile.lock 中的 BUNDLED
BUNDLED WITH ((version))
在版本 1 和版本 2 之间自动切换
Note:注意:
Before the next step, you should commit your Gemfile & Gemfile.lock, so that you can revert to bundler version 1 if needed在下一步之前,您应该提交您的 Gemfile 和 Gemfile.lock,以便您可以在需要时恢复到 bundler 版本 1
3- To upgrade from bundler 1 to 2, run: 3- 要从捆绑器 1 升级到 2,请运行:
bundle update --bundler
The answer is based on the official bundler update guide答案基于官方的bundler更新指南
使用检查已安装的捆绑程序版本
gem list bundler
要更改您的 bundler 默认版本,请使用bundle config default <the desired version>
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.