...without uninstalling the latest version.
I'm working on a project that uses Bundler 1.10, but I use Bundler 1.11 for all my other projects. Since this project is on 1.10, whenever I run any bundle
commands, my Gemfile.lock
changes due to the different formatting introduced by Bundler 1.11.
The only solution I've found so far is running all my commands like so:
bundle _1.10.6_ [command]
(from this answer here: https://stackoverflow.com/a/4373478/1612744)
Is there a better way? I'm using rbenv, not rvm.
You could use the rbenv-gemset plugin. Since an older version of a gem in an rbenv gemset doesn't override a newer version in the default gemset, you'd need to install bundler for each project, which is rather cumbersome.
cd ~/.rbenv/plugins; git clone git://github.com/jf/rbenv-gemset.git
) OR, if you use homebrew, brew install rbenv-gemset
gem uninstall -xI bundler
cd
to the projectecho bundler-1.11 > .rbenv-gemsets
("bundler-1.11" is the name of the gemset)gem install bundler
to get the current version, 1.11.*cd
to the projectecho bundler-1.10 > .rbenv-gemsets
("bundler-1.10" is the name of the gemset)gem install bundler -v 1.10.6
I ended up solving this with an alias and a bash function. In my ~/.bashrc
, I added this:
versioned_bundle() {
version_file=${PWD}/.bundle/version
if [[ -r $version_file ]]; then
version=$(<$version_file)
bundle _${version}_ "$@"
else
bundle "$@"
fi
}
alias bundle=versioned_bundle
As you can guess from the code, I also added a version
file to the .bundle/
directory in my project. That file's contents:
1.10.6
Whenever I run bundle
, my shell checks for a version file in the current directory, and if it finds it, runs that version of bundle.
$ cd project-with-old-bundle-version
$ bundle --version
1.10.6
$ cd anywhere-else
$ bundle --version
1.11.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With