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

ruby-install depends on xzcat, which is not available out of the box on all platforms

Open monfresh opened this issue 3 years ago • 9 comments

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

monfresh avatar Aug 03 '22 14:08 monfresh

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.

monfresh avatar Aug 03 '22 14:08 monfresh

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.

jmettraux avatar Aug 03 '22 14:08 jmettraux

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.

monfresh avatar Aug 03 '22 14:08 monfresh

https://github.com/postmodern/ruby-install/blob/master/.github/workflows/shunit2.yml

jmettraux avatar Aug 03 '22 14:08 jmettraux

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.

monfresh avatar Aug 03 '22 15:08 monfresh

We can add xz as a dependency to the homebrew formula.

postmodern avatar Aug 03 '22 19:08 postmodern

@postmodern Yes, please. That seems like a great solution.

monfresh avatar Aug 08 '22 14:08 monfresh

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.

postmodern avatar Aug 10 '22 03:08 postmodern

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.

monfresh avatar Aug 11 '22 14:08 monfresh

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.

postmodern avatar Aug 12 '22 03:08 postmodern

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

eregon avatar Aug 12 '22 11:08 eregon

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

mattmaddux avatar Aug 16 '22 15:08 mattmaddux

@postmodern would you be able to create the 0.8.5 tag? I can create a Homebrew PR if you'd like.

afturner avatar Aug 22 '22 15:08 afturner

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.

postmodern avatar Aug 22 '22 23:08 postmodern

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

monfresh avatar Sep 11 '22 02:09 monfresh

I submitted a PR to homebrew to update their formula.

postmodern avatar Sep 11 '22 09:09 postmodern

Awesome. Thanks! After a brew update and brew info ruby-install, I can see the dependency listed now.

monfresh avatar Sep 11 '22 16:09 monfresh