Aditya Naidu
Aditya Naidu

Reputation: 697

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?

Upvotes: 20

Views: 41561

Answers (3)

Ahmed Elkoussy
Ahmed Elkoussy

Reputation: 8588

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

Upvotes: 9

Jay Bennett
Jay Bennett

Reputation: 44

To change your bundler default version, use bundle config default <the desired version>.

Upvotes: -6

Xavier
Xavier

Reputation: 3513

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.

Upvotes: 16

Related Questions