postmodern / chruby

Changes the current Ruby
MIT License
2.86k stars 190 forks source link

Adjust version matching #320

Closed tvon closed 4 years ago

tvon commented 9 years ago

This is based off of https://github.com/postmodern/chruby/pull/319

Addresses #318

For example, given the following:

RUBIES=(
  /opt/rubies/ruby-2.0.0-p100
  /opt/rubies/ruby-2.1.1
  /opt/rubies/ruby-2.2.0
  /opt/rubies/ruby-2.2.1
  /opt/rubies/rbx-2.2.0
  /opt/rubies/rbx-2.2.1
)
jrafanie commented 9 years ago

Thank you for chruby/ruby-install.

As a user, this PR is great. I love chruby and recommend it to my team but dislike the current behavior. What's needed to get this reviewed/merged?

I get burned by this all the time when I install new rubies. Currently chruby 2.1 selects 2.2.1 when I want 2.1.5. Previously, chruby 2.0 selected 2.2.0 instead of 2.0.0. My brain just doesn't grok the current behavior.

I've considered removing rubies locally just so I don't have to deal with this problem but that seems silly.

tvon commented 9 years ago

@postmodern anything I can do to improve this?

postmodern commented 9 years ago

I'm a little hesitant about preferring ruby-$1* over just -$1*. See #278 which better sorts rubies by their version. I also experimented with adding precedence to matching.

tvon commented 9 years ago

My reasoning for ruby-* is that the only time people omit the implementation is when using MRI, at least so far as I've seen. In other words, if there is only a version number specified then we're looking for ruby-*, if there is more specified (rbx-2.2) then the "$1"* match will catch it. Unless I'm missing something, *-$1 could match 2.1 to rbx-2.1.1 which would be a mistake (I'm assuming even the Rubinius developers don't expect 2.1 to mean rbx-2.1).

Sorting would be an improvement either way as this PR does nothing to ensure that 2.1 picks the latest 2.1.x, but without other changes I don't think it would address 2.1 matching 2.2.1 instead of 2.1.x.

alindeman commented 9 years ago

chruby 2.1 selecting 2.2.1 is pretty confusing to me. I don't doubt there are some complicated issues around version preference, but this specific case is very surprising to me.

ccutrer commented 9 years ago

@postmodern any update on this? @tvon's reasoning on matching ruby-$1* rather than *-$1* seems pretty convincing to me.

FranklinYu commented 8 years ago

@postmodern Any update on this? When typing 2.1 I also expect ruby-2.1.1 (or the latest version of 2.1) while I would include the implementation if I am not using MRI, as stated by @tvon.