Hegwin.Me

The bitterest tears shed over graves are for words left unsaid and deeds left undone.

Run specific version of bundler

运行特定版本的 bundler

Ruby Little (Useless) Trick (Skill) series.

When you have two versions of bundler installed at the same time, say 2.0.1 and 1.17.2, by default bundle exec and other commands use the latest version of bundler; If you are maintaining an old program, then you may run into this magic problem due to the incompatibility of bundlers like this:

Bundler could not find compatible versions for gem "bundler".
    rails (= 5.0.3) was resolved to 5.0.3, which depends on
      bundler (>= 1.3.0, < 2.0)

  Current Bundler version.
    bundler (2.0.1)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?

In the case above, we can choose to upgrade rails 5.0.3 to 5.0.7, and similarly, 5.1.1 to 5.1.7, which is generally not destructive and can solve the problem very well.

What if you can't simply fix it by upgrading due to some dependencies? In this situation, you need to use a specific version of the bundler. And it works, too.

gem install bundler -v 1.17.2
bundle _1.17.2_ exec rspec

Add _version_ to the end of the bundle to use a specific version of bundler.


On a similar note, if you have multiple versions of rails installed and want to use a particular version to execute rails new, then something like this can be done:

rails _5.2.8_ new
< Back