10

I've just installed RVM on a new machine and when switching into a directory containing a .rvmrc file (which I've accepted) I'm getting:

ERROR: Neither sha256sum nor shasum found in the PATH

I'm on OS X 10.5.8. — Probably missing something somewhere. Any ideas what's going on and how to fix this?

polarblau
  • 17,649
  • 7
  • 63
  • 84

8 Answers8

19

My OpenSSL happened to not have a sha256 enc function for some reason:

$ openssl sha256
openssl:Error: 'sha256' is an invalid command.

After some googling, I found that there is an equivalent called gsha256sum that comes with the homebrew recipe "coreutils". After installing that (brew install coreutils), I had a gsha256sum binary in /usr/local/bin, so it was just a matter of symlinking it:

$ sudo ln -s /usr/local/bin/gsha256sum /usr/local/bin/sha256sum

That fixed it for me.

animuson
  • 53,861
  • 28
  • 137
  • 147
mike
  • 313
  • 2
  • 6
6

ciastek's answer worked for me until I tried to run rvm within a $() in a bash script - rvm couldn't see the sha256sum function. So I created a file called sha256sum with the following contents:

openssl sha256 "$@" | awk '{print $2}'

put it in ~/bin, made it executable, and added that folder to my path (and removed the function from my .bashrc).

(Many thanks to my coworker Rob for helping me find that fix.)

Lari Kirby
  • 61
  • 1
5

Means you're missing the binary in /usr/bin or your path is somehow missing /usr/bin. Open a new shell and run echo $PATH | grep '/usr/bin' and see if its returned. Also, ls -alh /usr/bin/shasum and make sure the binary is there and executable. There is no sha256sum on OS X, just shasum.

ddd
  • 1,925
  • 12
  • 19
  • Thanks for you answer. Seems `shasum` just doesn't exist. Any idea how to install it? – polarblau Sep 21 '11 at 16:29
  • No, thats something the OS installs. I'm inclined to believe your OS X install is a bit goofed. – ddd Sep 21 '11 at 23:00
  • Yep, you might be right. I'll have to install OS X 10.6 or even 10.7 anyways very soon. Let's hop that that fixes it. Thanks! – polarblau Sep 22 '11 at 04:09
4

On MacOS Sierra run

$ shasum -a 256 filename

Based on @vikas027 comment just add

alias sha256sum='shasum -a 256' to your ~/.zshrc

Mário Carvalho
  • 3,106
  • 4
  • 22
  • 26
  • 1
    cool. I have added `alias sha256sum='shasum -a 256'` to my `~/.zshrc` to not forget this again :) – vikas027 Apr 11 '18 at 05:43
2

I'm on a relatively fresh install of Lion (OS X 10.7.4). In my /usr/bin/ folder I had these files:

    -rw-rw-rw-  35 root  wheel   807B /usr/bin/shasum
    -rwxr-xr-x   1 root  wheel   7.5K /usr/bin/shasum5.10
    -rwxr-xr-x   1 root  wheel   7.5K /usr/bin/shasum5.12

I had a shasum, it just wasn't marked as executable. A quick sudo chmod a+x /usr/bin/shasum solved the issue for me.

JT.
  • 7,966
  • 1
  • 15
  • 10
2

In my opinion Leopard just doesn't have /usr/bin/shasum.

Take a look at shasum manpage - this manpage is only for Snow Leopard. Other manpages, like ls manpage (can't link to it, not enough reputation), are for previous versions of MacOS X.

Workaround: Use OpenSSL to calculate sha256 checksums.

Leopards' OpenSSL (0.9.7) doesn't handle sha256. Upgrade OpenSSL. I've used MacPorts (can't link to it, not enough reputation). OpenSSL's dependecy zlib 1.2.5 required to upgrade XCode to 3.1. Can I get Xcode for Leopard still? is helpful.

Alias sha256sum to OpenSSL and correct the way it formats an output. I've put in my .bash_profile:

function sha256sum() { openssl sha256 "$@" | awk '{print $2}'; }
Community
  • 1
  • 1
ciastek
  • 1,343
  • 12
  • 15
0

For mac os X 10.9.5 and you profile get /usr/bin path

 date +%s | shasum | base64 | head -c 32 ; echo
abkrim
  • 3,512
  • 7
  • 43
  • 69
0

And if you found yourself here in 2022 wondering what works on the latest Mac (Mac OS Big Sur). Do following.

 sudo brew install coreutils
 sudo ln -s /usr/bin/shasum<Version_for_your_installation>  /usr/local/bin/sha256sum

Amit Meena
  • 2,884
  • 2
  • 21
  • 33