Background: Our app requires a specific Ruby version. Currently the version is hard-coded in the install scripts (scripts/install/*) and in the obsolete .travis-ci.yml. One issue with this approach is that Dependabot is not aware of that version, so it suggests incompatible updates. Another issue is that it doesn't integrate with the GitHub Action ruby/setup-ruby (#150). I'd like to switch to a better method for specifying the Ruby version.
Here are the methods I am aware of and their tooling support (trickiest constraints in bold):
| Method |
Supported by |
Not supported by |
| .ruby-version |
rbenv, rvm, setup-ruby, asdfconfig required |
dependabot |
| .tool-versions |
setup-ruby, asdf |
rbenv, rvm, dependabot |
| Gemfile |
dependabot, rvm (with warning1), asdfconfig required; ref |
rbenv, setup-ruby |
Comments:
- rbenv and RVM are used in our install scripts and it would be nice to have good integration with them for local development. Currently we don't have good integration (
cd into the project doesn't automatically switch to the right Ruby version).
- setup-ruby was proposed in #150 and seems like the best tool for running on GitHub Actions natively, however I think it is more likely that we will use Docker (at least to start with) because GitHub Actions doesn't let us choose the Ubuntu version.
- asdf is a general-purpose language version manager that supports Ruby, Node.js etc. The reason I included it is that .tool-versions originates from asdf, and #150 proposed to use .tool-versions.
Here are the options I can think of:
A. Use Gemfile only.
We won't have rbenv integration, but we've managed so far without it.
We'll get RVM integration but with a warning1. I think the only way to disable this warning is to modify ~/.rvm/user/rvmrc_ignored, which I'd rather not do.
If we want to use setup-ruby in CI, we can add a step that extracts the version from the Gemfile and writes it to .ruby-version.
B. Use both .ruby-version and Gemfile.
This means the Ruby version will appear in two places and they'll have to be kept in sync. We can add a CI check to detect inconsistencies. Correction: Bundler automatically checks the version specifier in the Gemfile is satisfied, so no need for a custom check.
C. Make .ruby-version the single source of truth, and have the Gemfile automatically look up the version using the line
ruby "#{File.read(File.expand_path(".ruby-version", File.dirname(__FILE__)))}"
I think this option is too clever, and it means Dependabot won't automatically refresh its PRs when we update .ruby-version.
Thoughts?
1 RVM produces the following warning when you cd into a project and the version is detected using the Gemfile:
RVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too,
you can ignore these warnings with 'rvm rvmrc warning ignore /.../nztrain/Gemfile'.
To ignore the warning for all files run 'rvm rvmrc warning ignore allGemfiles'."
Background: Our app requires a specific Ruby version. Currently the version is hard-coded in the install scripts (scripts/install/*) and in the obsolete .travis-ci.yml. One issue with this approach is that Dependabot is not aware of that version, so it suggests incompatible updates. Another issue is that it doesn't integrate with the GitHub Action ruby/setup-ruby (#150). I'd like to switch to a better method for specifying the Ruby version.
Here are the methods I am aware of and their tooling support (trickiest constraints in bold):
Comments:
cdinto the project doesn't automatically switch to the right Ruby version).Here are the options I can think of:
A. Use Gemfile only.
We won't have rbenv integration, but we've managed so far without it.
We'll get RVM integration but with a warning1. I think the only way to disable this warning is to modify ~/.rvm/user/rvmrc_ignored, which I'd rather not do.
If we want to use setup-ruby in CI, we can add a step that extracts the version from the Gemfile and writes it to .ruby-version.
B. Use both .ruby-version and Gemfile.
This means the Ruby version will appear in two places and they'll have to be kept in sync.
We can add a CI check to detect inconsistencies.Correction: Bundler automatically checks the version specifier in the Gemfile is satisfied, so no need for a custom check.C. Make .ruby-version the single source of truth, and have the Gemfile automatically look up the version using the line
I think this option is too clever, and it means Dependabot won't automatically refresh its PRs when we update .ruby-version.
Thoughts?
1 RVM produces the following warning when you
cdinto a project and the version is detected using the Gemfile: