Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify minimum bundler version for Gemfile?

When my Gemfile is using :mri_20, and previous versions of bundler do not support that, is it a good idea to add

gem 'bundler', '~>1.3.5'

to the Gemfile? Is there a better way to enforce a minimum bundler version?

like image 467
Martin Avatar asked Aug 22 '13 14:08

Martin


People also ask

How do I change my current bundler version?

If you want to upgrade the Bundler version used by your application, you can run bundle update --bundler , and your lockfile will be regenerated using the latest version.

How do you update a gem to a specific version?

The correct way to update the version of a gem to a specific version is to specify the version you want in your Gemfile, then run bundle install . As for why your command line was failing, there is no -version option.


1 Answers

This won't have any affect on the bundler used to manage the gems in the Gemfile. The version of bundler that's used is the one that's available in your current ruby environment.

The best way to manage this is with gemsets - you can create a gemset with a known, working version of bundler and always switch to that gemset when working with that project.

To check the bundler version, run:

$ bundle --version
Bundler version 1.3.5

If you want to enforce the bundler version when running bundle install, put this at the top of the Gemfile:

# Gemfile
if Gem::Version.new(Bundler::VERSION) < Gem::Version.new('1.3.5')
  abort "Bundler version >= 1.3.5 is required"
end
like image 70
Jon Cairns Avatar answered Sep 19 '22 05:09

Jon Cairns