rbenv / ruby-build

A tool to download, compile, and install Ruby on Unix-like systems.
https://rbenv.org/man/ruby-build.1
MIT License
3.89k stars 785 forks source link

Ruby Incorrect Version Reported #2470

Closed sdubinsky closed 6 days ago

sdubinsky commented 1 week ago

On Fedora 42, I installed ruby 3.3.3 and got ruby 3.3.5. Prior to this, post-upgrade to fedora 42, I tried and failed to run bundle update. It failed because it couldn't find the ruby headers.

Steps to reproduce the behavior

  1. asdf update
  2. asdf install ruby 3.3.3
  3. asdf reshim

Expected vs. actual behavior

ruby -v should show 3.3.3, but it shows 3.3.5. I have confirmed that the actual ruby installed in .asdf/installs/ruby/3.3.3 says it's 3.3.5, specifically: ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [x86_64-linux]

Logs

install logs:

==> Downloading ruby-3.3.3.tar.gz...
-> curl -q -fL -o ruby-3.3.3.tar.gz https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.3.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 21.0M  100 21.0M    0     0  19.6M      0  0:00:01  0:00:01 --:--:-- 19.7M
==> Installing ruby-3.3.3...
ruby-build: using gmp from homebrew
-> ./configure "--prefix=$HOME/.asdf/installs/ruby/3.3.3" --enable-shared --with-gmp-dir=/home/linuxbrew/.linuxbrew/opt/gmp --with-ext=openssl,psych,+
-> make -j 12
-> make install
==> Installed ruby-3.3.3 to /home/deus-ex/.asdf/installs/ruby/3.3.3
sdubinsky commented 1 week ago

Other versions of ruby (3.1.2) install correctly. Is it possible the wrong version was uploaded?

mislav commented 1 week ago

ruby -v should show 3.3.3, but it shows 3.3.5. I have confirmed that the actual ruby installed in .asdf/installs/ruby/3.3.3 says it's 3.3.5

That's so weird! From the install output that you've shared, it looks like 3.3.3 was downloaded and compiled and placed in that directory. But what you're saying is even if you run the binary directly, it prints the wrong version? E.g. ~/.asdf/installs/ruby/3.3.3/bin/ruby -v

I really doubt that a wrong Ruby version was uploaded as "3.3.3", since the community would have caught that within minutes. I also wasn't able to replicate this problem locally (by using ruby-build directly, which asdf install invokes under the hood).

Does the problem persist if you try to nuke your existing 3.3.3 version and install it again?

sdubinsky commented 6 days ago

It's extremely weird! Yes, even running the binary directly says it's 3.3.5.

I nuked it two or three time at least trying to figure it out, including reinstalling asdf completely.

mislav commented 6 days ago

I'm not familiar with asdf, but you could try running ruby-build directly to try rule out that the problem comes from this project. Just download ruby-build anywhere, even to a temporary location, and try this:

rm -rf ~/.asdf/installs/ruby/3.3.3
/path/to/ruby-build/bin/ruby-build 3.3.3 ~/.asdf/installs/ruby/3.3.3

If that reproduces the same problem, then we can continue exploring. If the problem is gone, then I'm afraid that asdf or one of its plugins might have contributed to the problem. Sorry that I don't have better leads than that.

sdubinsky commented 6 days ago

It's still happening.

sdubinsky commented 6 days ago

I tried on git master

mislav commented 6 days ago

Bizarre. What do you get if you scan the download tarball directly?

$ curl -fsSL https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.3.tar.gz | tar xOz -- ruby-3.3.3/version.h | grep RUBY_VERSION_TEENY  
#define RUBY_VERSION_TEENY 3

It should print "3" for TEENY version of Ruby, instead of 5 like you're getting.

mislav commented 6 days ago

You could inspect the Ruby source mid-compilation to see if anything is odd. First, use ruby-build to install an isolated version of 3.3.3:

ruby-build --keep 3.3.3 /tmp/ruby-3.3.3 -- --disable-install-doc

Then, verify that /tmp/ruby-3.3.3/bin/ruby -e "puts RUBY_VERSION" prints 3.3.5 and exhibits the bug.

Now you can check what happened to its makefile. You can find Ruby's intermediate install location under a directory at ls -td $TMPDIR/ruby-build.*. This is where Ruby source files were compiled. You can try viewing the generated $TMPDIR/ruby-build.*/ruby-3.3.3/Makefile and see if MAJOR, MINOR, and TEENY values match.

If everything is consistently at "3.3.3" then I have no idea how the final binary prints "3.3.5". 😕

sdubinsky commented 6 days ago

Indeed the bug still exists and MAJOR, MINOR, and TEENY are all 3. If you have no other ideas I'll just assume it will go away eventually. Thanks!

mislav commented 6 days ago

Well, I'm out of ideas and I will close this because it really sounds like something specific to your system somehow. I don't think it's a huge problem; even if your app needs 3.3.3, running it on 3.3.5 should not result in any tangible differences. Also, you mentioned that compiling other Ruby versions doesn't exhibit the same problem.

Maybe as a last attempt in debugging you can print all your environment variables (with env), study the output and see if anything is in there that could affect Ruby runtime. Sorry I couldn't be of more help!