ruby-install
ruby-install copied to clipboard
ruby-install depends on xzcat, which is not available out of the box on all platforms
Description
I maintain a script that installs Ruby on a Mac. If Homebrew is not yet present on the machine, the script installs Homebrew, then installs chruby and ruby-install, then installs the latest Ruby with ruby-install. Up until the latest xzcat changes in 0.8.4, it was working perfectly. But now, on a machine that didn't have Homebrew prior to running my script, the Ruby compilation fails with:
xzcat: command not found
Instead of assuming xzcat is in the PATH, would it be better to use the full path using the brew prefix, like $(brew --prefix)/xzcat?
cc @jmettraux
I originally thought that xzcat was installed by Homebrew because when I do which xzcat, it shows me /usr/local/bin/xzcat on Intel Macs and /opt/homebrew/bin/xzcat on Apple Silicon Macs. However, it seems like that might only be the case on certain macOS versions. I have an Intel Mac on Big Sur, and after installing Homebrew and restarting the terminal, xzcat is still not found. So, I don't think it's a good idea to assume it's available everywhere.
So, I don't think it's a good idea to assume it's available everywhere.
Since you install Homebrew, can you brew install xzcat right before installing ruby-install?
If it's too much of a hassle, I'm totally OK with my change being reverted, since OpenBSD usage compared to MacOSX usage is tiny.
OK, I found the issue. The reason why xzcat was available on my other machines, but not the Big Sur one is because I had somehow installed xz with Homebrew, probably as a dependency of another tool I installed. So, I can confirm that xzcat is NOT available by default on a Mac.
As for my script, I can fix this by adding xz (not xzcat because that formula doesn't exist on Homebrew) to my script's Brewfile.
https://github.com/postmodern/ruby-install/blob/master/.github/workflows/shunit2.yml
Yeah, the macOS images from GitHub don't simulate a brand new Mac. They already come with a bunch of stuff installed on them, so this type of bug won't be found there. Here's what's included:
https://github.com/actions/virtual-environments/blob/macOS-11/20220710.1/images/macos/macos-11-Readme.md
It installs zstd, which depends on xz, which is why xzcat is available on that image.
We can add xz as a dependency to the homebrew formula.
@postmodern Yes, please. That seems like a great solution.
xz is now a proper dependency of chruby. I assume homebrew should have synchronized chruby's homebrew formula into their repository automatically by now? Or do I have to tag a new release? I haven't kept up to speed with how homebrew updates their formulas; we used to have to manually submit a PR to them each time.
Thanks! It doesn't look like Homebrew automatically synchronizes. When I run brew info ruby-install, I still see version 0.8.4 and it doesn't list any dependencies. I've never released anything on Homebrew so I'm not sure what the process is now.
Hmm, guess I'll have to release 0.8.4.1 with the added dependency to get it updated in homebrew; not sure if adding a missing dependency warrants 0.8.5.
not sure if adding a missing dependency warrants
0.8.5.
IMHO yes, adding the missing dependency is a bug fix and deserves a patch release. Regarding Homebrew I think a PR is needed to https://github.com/Homebrew/homebrew-core/pulls
FYI, for anyone needing to install before that PR is done, the brew package is xz not xzcat.
So just run
brew install xz
before running
ruby-install ruby
@postmodern would you be able to create the 0.8.5 tag? I can create a Homebrew PR if you'd like.
OK ruby-install 0.8.5 has now been tagged and ruby-install's own copy of its homebrew formula has been updated. Hopefully, homebrew will automatically copy in the updated homebrew formula with the xz dependency.
It looks like Homebrew didn't pick up the depends_on "xz" part. Here's the formula that's on Homebrew right now for version 0.8.5: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/ruby-install.rb
I submitted a PR to homebrew to update their formula.
Awesome. Thanks! After a brew update and brew info ruby-install, I can see the dependency listed now.