1

I want to install bundler with a specific version written in Gemfile.lock. Do you know how to do it? I want to let ci like Jenkins automatically install bundler of the version.

BUNDLED WITH
   1.13.5
diveintohacking
  • 4,783
  • 6
  • 29
  • 43
  • If I am not wrong, Are you asking, for how to install bundler based on the specific versions of the gems installed? – Emjey Jul 07 '17 at 06:00
  • AFAIK, bundler reads the gemfile and installs gems based on versions specified in lock file and what you are asking is bundler installs/upgrades itself based on version written in lock file...I doubt it. – Md. Farhan Memon Jul 07 '17 at 06:21
  • Don't think you can do so. bundler helps you manages gemfiles and therefore you can't use it to manage itself. If you want to specify the version of it I think it would be better for you to run it as a script (if you host on your own server), if you are using heroku I don't think you can specify it. [Read More Here](https://devcenter.heroku.com/articles/bundler-version#why-can-t-the-bundler-version-be-configured) – yihyang Jul 07 '17 at 06:30
  • My intention is to install a specific version of bundler. The version depends on Gemfile.lock file. – diveintohacking Jul 07 '17 at 08:57

3 Answers3

4

You might try a bit of shell scripting: gem install bundler -v $(tail -n1 Gemfile.lock)

cainlevy
  • 181
  • 4
  • Not sure if the `BUNDLED WITH` can appear in other parts of `Gemfile.lock`, but this might be a more robust way: `grep -A 1 'BUNDLED WITH' Gemfile.lock | tail -n 1 | xargs`. Takes the "BUNDLED WITH" line and the line after it, takes the last line of those, then trims leading and trailing whitespace. – V. Rubinetti Mar 08 '23 at 23:18
2

Probably a bit late to the party, but bundler 2.3 does this for you by default. See https://bundler.io/blog/2022/01/23/bundler-v2-3.html.

deivid
  • 4,808
  • 2
  • 33
  • 38
-2

Works for me :)

InfoMiner
  • 69
  • 6