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

Version compares Date with Git Sha

Open quintrino opened this issue 5 years ago • 7 comments

https://github.com/asdf-vm/asdf-ruby/blob/de1fb60e977e784cbaa7a9d50384dcae7c32dbb1/lib/utils.sh#L20

This appears to be comparing the date of ruby-build (20190401) with an earlier sha of the ruby build repo. (44b0c75)

This means it always downloads the whole repo every time. Just wanted to raise it in case you weren't aware of it. Apologies if I'm reading something wrong.

quintrino avatar Jun 11 '19 11:06 quintrino

@quintrino thanks for reporting. I believe the original intent of this code was to download the $RUBY_BUILD_VERSION version of ruby-build when the currently downloaded version doesn't match $RUBY_BUILD_VERSION. This should result in later checks returning false, since the versions would then match.

So what you are observing makes sense for the first run of this code after it has been updated (e.g. new asdf-ruby code with a new $RUBY_BUILD_VERSION), but subsequent runs should not download the repo. Can you confirm this is happening? You can check by running an asdf-ruby command multiple times (asdf list-all ruby would be a good one).

Stratus3D avatar Jun 17 '19 17:06 Stratus3D

Also, just FYI ruby-build uses dates for the tag names, so when you see a date you are actually seeing the tag name.

Stratus3D avatar Jun 17 '19 17:06 Stratus3D

Yep, I originally noticed it because I was scripting a number of asdf list-all commands and while node and elixir would be relatively quick ruby would process a full download every time.

Tested again now 5 seconds apart and it downloads multiple times.

quintrino avatar Jun 18 '19 00:06 quintrino

@quintrino I see the bug. We check the commit sha against the output of ruby-build --version. My guess is that when we use a commit hash instead of a tag ruby-build returns the previous tag name. This is a bug, and it only manifests when we are using a commit sha.

We recently updated to a newer tag, so in the meantime the latest version of this plugin should not have this problem.

Stratus3D avatar Jun 18 '19 12:06 Stratus3D

So reading over the commit that introduced the commit sha (https://github.com/asdf-vm/asdf-ruby/commit/7bbdd8618070c5a033bde024419bcbb74ed1bca7) I'm guessing that ruby-build probably updated their build to include 2.6.3 but didn't update the version number, meaning that asdf-ruby didn't detect a new version and therefore wouldn't allow the download of 2.6.3 (because the old version would still have had a current version number, but be from before 2.6.3 was added)

Then, after switching from the version tag to sha it triggered a download and got the latest version allowing the developer to download 2.6.3 but also causing the bug of always downloading the latest version.

quintrino avatar Jun 18 '19 23:06 quintrino

Just tested it now with the latest version. (I've truncated the output from list-all ruby)

~  asdf plugin-update ruby
Updating ruby... Already up to date. ~  asdf list-all ruby
Downloading ruby-build... Cloning into 'ruby-build-source'... remote: Enumerating objects: 48, done. remote: Counting objects: 100% (48/48), done. remote: Compressing objects: 100% (28/28), done. remote: Total 9760 (delta 19), reused 43 (delta 14), pack-reused 9712 Receiving objects: 100% (9760/9760), 2.08 MiB | 1.20 MiB/s, done. Resolving deltas: 100% (6345/6345), done. Note: checking out 'v20190615'.

You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:

git checkout -b

HEAD is now at ac92ec0 Merge pull request #1306 from olivierlacan/2-7-0-preview1 1.8.5-p52 1.8.5-p113 1.8.5-p114 ~  asdf list-all ruby
Downloading ruby-build... Cloning into 'ruby-build-source'... remote: Enumerating objects: 48, done. remote: Counting objects: 100% (48/48), done. remote: Compressing objects: 100% (28/28), done. remote: Total 9760 (delta 19), reused 43 (delta 14), pack-reused 9712 Receiving objects: 100% (9760/9760), 2.08 MiB | 360.00 KiB/s, done. Resolving deltas: 100% (6345/6345), done. Note: checking out 'v20190615'.

You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:

git checkout -b

HEAD is now at ac92ec0 Merge pull request #1306 from olivierlacan/2-7-0-preview1 1.8.5-p52 1.8.5-p113 1.8.5-p114

quintrino avatar Jun 18 '19 23:06 quintrino

Ah, looks like

https://github.com/asdf-vm/asdf-ruby/commit/9a7212194a1d4df7ecce77d1ed929defce832368 adds in the new version of Ruby Build but the commit that put in the SHA also added removed the V from RUBY_BUILD_TAG="v$RUBY_BUILD_VERSION" which is now instead RUBY_BUILD_TAG="$RUBY_BUILD_VERSION"

I believe adding the v back after the equals with make the build complete the check and not download.

quintrino avatar Jun 18 '19 23:06 quintrino

I don't believe this is an issue anymore. @quintrino if you are still having issues let me know.

Stratus3D avatar Mar 20 '24 18:03 Stratus3D