setup-ruby icon indicating copy to clipboard operation
setup-ruby copied to clipboard

How about changing interpretation of version string

Open znz opened this issue 2 years ago • 5 comments

Many users who wants use 3.0.x write ruby-version: 3.0 by mistake.

3.0 interpreted as 3 on GitHub Actions.

For example, following workflow step prints 3 only.

        env:
          env_var: 3.0
        run: |
          set -x
          echo ${env_var}

So I propose changing the meaning of 3 (and 3.0 on workflow files) use 3.0.x, and 3.x (or something) use latest 3.x.x.

After this change, many users can write 3.0 intentionally, and some (probably less) users who want use latest 3.x.x can write 3.x or something instead.

znz avatar Jan 17 '23 06:01 znz

In https://github.com/actions/runner/issues/849 , 3.10 is another problem. And ruby's yaml parser also parses 3.10 as 3.1 too. But ruby's yaml parser parses 3.0 as 3.0, so it is more important difference.

znz avatar Jan 17 '23 06:01 znz

I thought about this too in the past, but it means there is no way to express "Ruby >= 3 < 4" then, i.e. Ruby 3.x. I'm kind of negative to introduce such hacks and exceptions, because it can lead to more confusion and inconsistency.

I still think this is a bug of the GitHub Actions YAML parser, because it can know the difference but doesn't use it. No idea if it will ever be fixed though. An alternative might be if an action can get its inputs as the original strings in YAML, not parsed to numbers or anything. That would also work. core.getInput() is already always a string, but it is value.toString vs the original string.

.10 is not an issue as few Ruby versions have a .10, and those that do have it have it as patch so then it's not a float anymore anyway (e.g. 2.4.10).

eregon avatar Jan 17 '23 12:01 eregon

I filed https://github.com/actions/toolkit/issues/1320, if that's done that would be enough.

eregon avatar Jan 24 '23 12:01 eregon

Another idea is maybe we could warn when we get 3 as the input. And then we could say use ruby-3 if you really want CRuby >= 3 < 4, that's actually a fairly simple alternative way to express CRuby >= 3 < 4.

eregon avatar Jan 24 '23 12:01 eregon

In actions/runner#849 , 3.10 is another problem. And ruby's yaml parser also parses 3.10 as 3.1 too. But ruby's yaml parser parses 3.0 as 3.0, so it is more important difference.

I was just reading about this as well, looks like the solution is to just wrap it in single quotes as such:

env:
  env_var: '3.0'

Should fix the problem for now at least!

eliduke avatar Mar 06 '24 23:03 eliduke