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

MacOS ruby-install: Fails with `-r: No such file or directory`

Open coffeegist opened this issue 1 year ago • 3 comments

Description

When verifying the sha1 hash of the downloaded ruby-x-y-z.tar.xz file, there is no hash calculated on MacOS (14.5). This is due to the sha1 -r option provided in the ruby-install process. On MacOS, running sha1 -r results in the result, -r: No such file or directory. This is reported in the output by ruby-install.

Steps To Reproduce

Steps to reproduce the bug:

  1. $ ruby-install -D ruby 3.1.3

Expected Behavior

The application should run sha1 <filename> instead, resulting in a successful pass.

Actual Behavior

$ ruby-install -D ruby 3.1.3
>>> Installing ruby 3.1.3 into /Users/user/.rubies/ruby-3.1.3 ...
>>> Installing dependencies for ruby 3.1.3 ...
Warning: automake 1.17 is already installed and up-to-date.
To reinstall 1.17, run:
  brew reinstall automake
Warning: bison 3.8.2 is already installed and up-to-date.
To reinstall 3.8.2, run:
  brew reinstall bison
Warning: readline 8.2.10 is already installed and up-to-date.
To reinstall 8.2.10, run:
  brew reinstall readline
Warning: libyaml 0.2.5 is already installed and up-to-date.
To reinstall 0.2.5, run:
  brew reinstall libyaml
Warning: gdbm 1.24 is already installed and up-to-date.
To reinstall 1.24, run:
  brew reinstall gdbm
Warning: libffi 3.4.6 is already installed and up-to-date.
To reinstall 3.4.6, run:
  brew reinstall libffi
Warning: openssl@3 3.3.1 is already installed and up-to-date.
To reinstall 3.3.1, run:
  brew reinstall openssl@3
>>> Downloading https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.3.tar.xz into /Users/user/src ...
>>> Verifying ruby-3.1.3.tar.xz ...
-r: No such file or directory
!!! Invalid sha1 checksum for /Users/user/src/ruby-3.1.3.tar.xz
!!!   expected: 12998178c3d17fa8a9d8300c7caab460b0e698c0
!!!   actual:
!!! Verification of ruby-3.1.3.tar.xz failed!

Environment

$  ~ ruby-install --version
ruby-install: 0.9.3
$  ~ uname -a
Darwin hostname.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:09:52 PDT 2024; root:xnu-10063.121.3~5/RELEASE_X86_64 x86_64
$  ~ cc --version
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: x86_64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$  ~ openssl version
OpenSSL 3.3.1 4 Jun 2024 (Library: OpenSSL 3.3.1 4 Jun 2024)

coffeegist avatar Aug 06 '24 03:08 coffeegist

Odd, appears that macOS changed their sha1 command. Which version of macOS are you running? Did you upgrade recently? I am assuming this is a recent change? Also could you double check that sha1 isn't aliased to some other command? Also could you double check that the /Users/user/src/ruby-3.1.3.tar.xz file actually does exist?

postmodern avatar Aug 06 '24 07:08 postmodern

I cannot reproduce this on macOS Sonoma 14.5. The sha1 command does not exist by default on macOS Sonoma (and possibly older versions too). In my case, ruby-install finds these other commands first:

>>> Verifying ruby-3.1.5.tar.xz ...
[DEBUG] md5sum /Users/moncef/src/ruby-3.1.5.tar.xz
[DEBUG] sha1sum /Users/moncef/src/ruby-3.1.5.tar.xz
[DEBUG] sha256sum /Users/moncef/src/ruby-3.1.5.tar.xz
[DEBUG] sha512sum /Users/moncef/src/ruby-3.1.5.tar.xz

monfresh avatar Aug 07 '24 22:08 monfresh

@postmodern sorry for the delay. I'm on macOS 14.5 and can confirm what @monfresh said in that sha1 doesn't seem to have existed by default. The sha1 installed on my machine seems to be part of a brew install for hashcash. I did confirm that the /Users/user/src/ruby-3.1.3.tar.xz file existed, manually verified the hash and then added the argument to disable hash checking on that file to get it to continue. Apologies for the spin-up on this edge case of a sha1 tool existing that normally doesn't

coffeegist avatar Aug 08 '24 14:08 coffeegist

Closing this issue as it appears to be caused by hashcash installing it's own sha1 command utility.

postmodern avatar Jan 29 '25 23:01 postmodern