andrewthauer / asdf-alias

Version aliases for asdf-vm
MIT License
26 stars 7 forks source link

Alias versions break some auto-reshim mechanisms #10

Closed ofalvai closed 3 months ago

ofalvai commented 3 months ago

Describe the bug

I found an interesting asdf edge case I'm not sure how to solve. It's related to this plugin and the auto-reshimming feature of some language plugins like Ruby. I opened a ticket in the asdf-ruby repo but I also want to raise it here because I realized this is a generic problem related to alias versions.

The problem: this hook uses the Ruby constant RUBY_VERSION, and when the active Ruby version is an alias version (which is a symlink to a concrete version), this results in an incorrect reshim command. For example, when the active version is 3.2, the executed command is asdf reshim 3.2.0 instead of asdf reshim 3.2.

Does anyone have a clever idea to work around this? One option would be to relax the reshim command to reshim all known Ruby versions, but that would be bad for performance. The auto-reshim in asdf-node and asdf-python do this exactly, but I hope there is a better way.

Steps to reproduce

Expected behavior

Screenshots

Additional context

andrewthauer commented 3 months ago

I've never had a lot of luck using aliases for ruby versions in any tool. Ruby can be finicky and strict about the versions of gems being used during execution. Especially when it comes to gems that install / compile native extensions which link to specific absolute paths.

Having a quick look at the asdf-ruby plugin, the hook you describe is a rubygem plugin and this must be where the RUBY_VERSION is coming from. It doesn't appear the asdf-ruby plugin does much with this itself and just registers the path containing the hook to ruby gems. If there is a workaround it would likely be in this realm.

Since this is unlikely an issue with the asdf-alias plugin itself, I'm going to close the issue. I've linked this to https://github.com/asdf-vm/asdf-ruby/issues/399 for reference.

NOTE: I've switched from asdf to mise which doesn't require shimming. You could try it you may and have better luck with your particular use case. However, I can't say for sure since I don't alias ruby versions for the reasons I mentioned above.