19

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?

Aditya Naidu
  • 697
  • 2
  • 7
  • 18
  • Its September 2019. Still, there is no way to forcefully use a specific version of bundler from all of the installed ones? – M. Habib Sep 21 '19 at 12:48

3 Answers3

15

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.

Xavier
  • 3,423
  • 23
  • 36
  • 4
    After doing so, When I run the bundler --version command, it still shows 1.11.2, how so? – Aditya Naidu Apr 18 '16 at 20:34
  • You have to add `_1.3.6_` every time unless you remove your other versions – Xavier Apr 18 '16 at 20:36
  • 2
    I just updated my answer. Another good question would be, how to force rubygems to use a specific version of an installed gem's executable? As for that, I do not know. I think I'll make a question for that though, because now I'm curious. – Xavier Apr 18 '16 at 20:38
  • http://stackoverflow.com/questions/36703958/how-to-force-rubygems-or-shell-to-use-a-certain-version-of-a-gems-executable – Xavier Apr 18 '16 at 20:44
  • 1
    You can use `bundle exec` to run the command you want with the bundler version specified in your project. E.g.: `bundle exec rails s` will run the `rails s` with the bundler specified in the Gemfile of your current project. – Oleksandr Kruk Mar 22 '19 at 10:35
7

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

Ahmed Elkoussy
  • 8,162
  • 10
  • 60
  • 85
-6

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