Repository navigation
Support .ruby-version #31
Description
Activity
I was wondering if there is a workaround available, like
- name: Set up Ruby uses: actions/setup-ruby@v1 with: ruby-version: "{{ cat('.ruby-version') }}"
However I was not able to figure out how to do that yet :(
I found a workaround in actions/setup-node repo.
- run: echo "::set-output name=RUBY_VERSION::$(cat .ruby-version)" id: rbenv - uses: actions/setup-ruby@v1 with: ruby-version: "${{ steps.rbenv.outputs.RUBY_VERSION }}"Reacted by Paulo Fidalgo, Fionn Masuhr, Masatoshi Iwasaki, David Koerdt, Mike McQuaid, Masafumi Koba, 🍣, Techbrunch, Maros Hluska and Santiago CastroReacted by Mike McQuaid, Maros Hluska and Santiago Castrohappy to see the workaround ☝️ - leaving as an enhancement for consideration
@bryanmacfarlane To be honest, and without any anger or nothing, I want to point out that supporting
.ruby-versionshould not be seen as an "enhancement" but as a requirement for the ruby community. When any company starts a Ruby project they will first choose between rvm or rbenv, most of them. And the next step will be to create a.ruby-versionfile to easily create a reproducible environment for devs and continuous integration, which is supported by both rbenv and rvm.Thus I think we should consider supporting the
.ruby-versionreally as a requirement to consider "setup-ruby" good enough for any Ruby project. Right now a lot of people are just not using it and instead using https://github.com/eregon/use-ruby-action or https://github.com/masa-iwasaki/setup-rbenv.I think it's fine and great that people are creating actions on the marketplace but for some very popular actions, the ones from GitHub should really cover most use cases otherwise we'll endup with a marketplace like the npm registry where you spend half a day trying to find the "right" ruby action that works well..
Thanks for consideration!
PS: Maybe @eregon, creator of use-ruby-action you have some thoughts about this too? Thanks!
Reacted by Masafumi Koba, Adrien Rey-Jarthon, Steffen Kötte, Mike Goggin and Benjamin QuorningI implemented it in
use-ruby-action(issue: ruby/setup-ruby#4).
It's really trivial.I think longer term we'll want most (all maybe) features of use-ruby-action in this repo: #44
- added a commit that references this issue
on Feb 14, 2020 - added 5 commits that reference this issue
on Feb 28, 2020 I saw the same concept works for
user-ruby-actionas following: (tested and working)- name: Install Ruby version from .ruby-version uses: eregon/use-ruby-action@masterIt would be nice if that supported the same way here.
Given that someone may be AFK...
eregon/use-ruby-action@master has moved to ruby/setup-ruby.
For info specific to .ruby_version, see supported-version-syntax.
ruby/setup-ruby supports almost all Ruby versions since 2.2, fully tested head/master builds, and all platforms are supported. Understandably, GitHub prefers not to host EOL software, but others can, as does ruby/setup-ruby. I'm not recommending using it.
Also, most actions that are past development stage are not using master. Or, master may be dangerous, as new features may be developed there. So, use
uses: ruby/setup-ruby@v1instead of
uses: ruby/setup-ruby@masterThat got me confused as I was trying to install my ruby version which I can't give as an argument for setup-ruby, and the only way mentioned as in the example:
- uses: ruby/setup-ruby@v1 with: ruby-version: 2.6Until I landed in an example that does so as my last comment, I wonder why that not specified in the docs here, if that is the official one!
Forgive me, I'm confused.
why that not specified in the docs here
here is actions/setup-ruby, which is the action supported by GitHub.
My post was mostly referring to ruby/setup-ruby (which is where eregon/use-ruby-action moved to) which is within the Ruby organization, and is not supported by GitHub.
If, using ruby/setup-ruby, you want to read Ruby version info from the .ruby-version file, use:
- uses: ruby/setup-ruby@v1 with: ruby-version: .ruby-versionYou can also not include the
ruby-version:input, but specifying.ruby-versionmakes it very clear where the info is retrieved from.Thanks, @MSP-Greg for clarification, both have the same name really confused me, between Ruby and Actions, and BTW when I used:
uses: ruby/setup-ruby@v1without
withclause it worked as wellReacted by MSP-Greg, Benoit Daloze, serenematt-babbel, Hyeonho Lee (Ethan) and Leo M. Peres@mo-rubikal Glad you found how to use it.
Do you think the docs at https://github.com/ruby/setup-ruby#usage are clear enough about this?
If not, please file an issue and I'll try to improve them.

Many ruby projects include a
.ruby-versionfile in the root directory, containing the version of Ruby needed.Tools such as
rvm,rbenvandchrubyall recognise and use this file.This is not unlike the
.nvmrcfile often used in Node projects, and thesetup-nodeaction has a discussion on potentially using the contents of that file as the node version if nowith:argument is specified. (actions/setup-node#32)I would suggest that
setup-rubymight consider a similar approach, where if no explicit ruby version is given, look for a.ruby-versionfile and use the version contained within.