简体   繁体   中英

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:

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 --version

I want to use version 1.3.6 How do I swap the current version of bundler with the available ones?

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. (You might try it, though). However, you can install the version you like and force the shell/rubygems to use that version:

$ 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.

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.

Sept 2019

If you want to upgrade bundler 1 to 2 , then you should do the following:

1- The first step in upgrading to Bundler 2 is installing the Bundler 2 gem by running:

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

Note:

Before the next step, you should commit your Gemfile & Gemfile.lock, so that you can revert to bundler version 1 if needed

3- To upgrade from bundler 1 to 2, run:

bundle update --bundler

The answer is based on the official bundler update guide

使用检查已安装的捆绑程序版本

gem list bundler

要更改您的 bundler 默认版本,请使用bundle config default <the desired version>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM