Skip to content

Install Bundler in older Ruby versions#501

Open
leoarnold wants to merge 1 commit into
asdf-vm:masterfrom
leoarnold:leoarnold/ensure-bundler
Open

Install Bundler in older Ruby versions#501
leoarnold wants to merge 1 commit into
asdf-vm:masterfrom
leoarnold:leoarnold/ensure-bundler

Conversation

@leoarnold
Copy link
Copy Markdown

@leoarnold leoarnold commented May 25, 2026

In Ruby versions prior to 2.6 is not installed by default. For the skilled asdf user, the solution may seem pretty simple

gem install bundler
asdf reshim ruby

This will run into yet another problem because gem command will simply select the latest available version of bundler and then tell you that it is not compatible with your Ruby version. Depending on the version of RubyGems, it may not even suggest a compatible version of bundler.

For the casual asdf user, things get even more confusing because they probably also have a contemporary version of Ruby installed (which as the bundle command shimmed), so asdf will suggest to use the modern Ruby version (instead of telling you how to get bundler installed):

$ bundle
No version is set for command bundle
Consider adding one of the following versions in your config file at /home/johndoe/.tool-versions
ruby 4.0.5

Therefore it makes sense to have the asdf Ruby plugin install bundler by default. Any compatible version of Bundler will do since Gemfile.lock specifies the Bundler version required by the project, and the bundle command will respond to this.

In this commit, we choose to address the issue in the following way:

  • Ruby v1.8 and below: This is expert territory and will be skipped. Ruby v1.8.7 reached end of life on 2014-07-31 and many projects using this version of below may not even use bundler in the first place.
  • Ruby v2.6 and above: The bundler gem is installed by default. We still check for the gem, but the test should pass and nothing needs to be done.
  • Ruby v1.9 to v2.5: Here we need to install a version of Bundler. Version 1.17.3 is the last v1 release of Bundler and widely accepted as the trusty version of Bundler to use when in doubt, so we will do just that.

With this change, bundler will be installed and shimmed even when using legacy versions of Ruby, so even casual users of asdf will have a pleasent experience.

In Ruby versions prior to 2.6 is not installed by default.
For the skilled `asdf` user, the solution may _seem_ pretty simple

```shell
gem install bundler
asdf reshim ruby
```

This will run into yet another problem because `gem` command
will simply select the latest available version of `bundler`
and then tell you that it is not compatible with your Ruby version.
Depending on the version of RubyGems, it may not even suggest
a compatible version of `bundler.

For the casual `asdf` user, things get even more confusing
because they probably also have a contemporary version of Ruby
installed (which as the `bundle` command shimmed),
so `asdf` will suggest to use the modern Ruby version
(instead of telling you how to get `bundler` installed):

```shell
$ bundle
No version is set for command bundle
Consider adding one of the following versions in your config file at /home/johndoe/.tool-versions
ruby 4.0.5
```

Therefore it makes sense to have the `asdf` Ruby plugin install `bundler` by default.
Any compatible version of Bundler will do since `Gemfile.lock` specifies the Bundler version
required by the project, and the `bundle` command will respond to this.

In this commit, we choose to address the issue in the following way:

- Ruby v1.8 and below: This is expert territory and will be skipped.
  Ruby v1.8.7 reached end of life on 2014-07-31 and many projects
  using this version of below may not even use `bundler` in the first place.
- Ruby v2.6 and above: The `bundler` gem is installed by default.
  We still check for the gem, but the test should pass and nothing needs to be done.
- Ruby v1.9 to v2.5: Here we need to install a version of Bundler.
  Version 1.17.3 is the last v1 release of Bundler and widely accepted
  as the trusty version of Bundler to use when in doubt, so we will do just that.

With this change, `bundler` will be installed and shimmed even when using legacy versions of Ruby,
so even casual users of `asdf` will have a pleasent experience.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant