DEV Community

Erik Guzman
Erik Guzman

Posted on • Updated on

TIL: Bundle install with a specific version of Bundler

The challenge with working on multiple Ruby on Rails projects is coming across issues conflicting dependencies between projects. One issue I have been having has been with the version of bundler. One project I am working on depends on bundler v2 and another depends on bundler v1 running on the same Ruby version.

Upgrading bundler version for the project using bundler v1 is not an option right now and trying to do any bundle installs can get very annoying since it will be using the wrong version of bundler for the Gemlock.

After doing some web searching for a potential solution I found out about this funky annotation for telling bundle what version of the bundler gem you would like to use:

bundle _1.13_ install
Enter fullscreen mode Exit fullscreen mode

It's a weird argument but it works. So next time you have a different major bundler versions across projects try using this.

Top comments (4)

Collapse
 
olistik profile image
olistik

Hi @talk2megooseman :-) I recently had the need to use a specific version of Bundler and found out that the 2 underscores version doesn't work:

λ ruby -v
ruby 2.7.3p183 (2021-04-05 revision 6847ee089d) [x86_64-linux]
Enter fullscreen mode Exit fullscreen mode
λ bundle __1.17.3__ --version
Could not find command "__1.17.3__".
Enter fullscreen mode Exit fullscreen mode

Using 1 underscore, before and after the version, works:

λ bundle _1.17.3_ --version
Bundler version 1.17.3
Enter fullscreen mode Exit fullscreen mode
Collapse
 
talk2megooseman profile image
Erik Guzman

Awesome, let me update the article

Collapse
 
olistik profile image
olistik

You're welcome. 🙂🎩

I suppose you could also get rid of:

Yep, that is 2 underscores before and after the version you would need to use.

Or change it to say it's 1 underscore.

Collapse
 
jgomo3 profile image
Jesús Gómez • Edited

I was trying to make rails new ... to use an specific version of bundler so the Gemfile.lock would state that version in the end of that file.

I tried with:

bundle _x.x.x_ exec rails new ...

But it didn't work, because bundle exec needs a Gemfile to begin with.

What I did was to remove all the bundlers I had installed in the specific Ruby version I wanted to use and keep only the specific version of bundler I wanted.