I spent most of the day trying to install Ruby on my MacOs (from 2014, version 10.11.6 -- I can't update to higher). I finally got chruby installed with Homebrew and then tried to follow the insructions here on github for installing ruby. The first instruction is to run

wget https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.0.tar.xz

But when I ran it, it said -bash: wget: command not found

Then I tried ls to see what would happen(as another random command from the terminal) and i got the same response: bash: ls: command not found

Then I tried to open and run programs from the command line and got the same response. I turned the computer on and off and still no change.

Interestingly, I can run homebrew commands

brew doctor prints an output, and I can do cd

vim is unavailable as is nano

The only thing I touched in my .bash_profile was this line that I added

# source /Users/mm/homebrew/opt/chruby/share/chruby/chruby.sh

but it's the same whether I leave it commented or uncomment it out.

How can I restore the terminal commands (with related question, why did this happen)?

  • It happened because the PATH environment variable is unset or set incorrectly. What do you get from this: echo "$PATH"
    – Linc D.
    Dec 24, 2023 at 3:25
  • Interestingly, I can run homebrew commands : I don't find it that much interesting. brew is usually in /usr/local/bin, while ls is usually in /bin. So just fix your PATH, and off you go. Jan 5 at 13:54

1 Answer 1


First, open a new tab/window in Terminal and check whether the problem remains. If it does:

  • Run echo $PATH to see what is wrong with it (in such cases, it's usually either empty or set to a strange value which might help in step 3 below).
  • Run export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin in your current shell to temporarily restore the path.
  • Then look into the startup files of your shell (.profile, .bashrc and anything called from there) to check where exactly PATH gets set wrong.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .