chruby: "chruby: command not found" after install though homebrew

  1. Install through brew $ brew install chruby
  2. Add source /usr/local/share/chruby/chruby.sh to ~/.bashrc
  3. Restart terminal
  4. $ chruby => chruby: command not found

Don’t appear to have an /etc/profile.d/chruby.sh file or /etc/profile.d/ dir. $ cd /etc/profile.d/ => cd: /etc/profile.d/: No such file or directory

—What am I doing wrong?

Mac OS X 10.7.5. Homebrew 0.9.4 chruby 0.3.4

About this issue

  • Original URL
  • State: closed
  • Created 14 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

Hey devs, just adding this for completion sake if you’re using zsh as your shell and you have the same “chruby: command not found” error.

# Add the following to the ~/.bash_profile or ~/.zshrc file:
source $(brew --prefix)/opt/chruby/share/chruby/chruby.sh

reference: https://formulae.brew.sh/formula/chruby

Does it show that I’m a noob? 😣 For the sake of the next noob with the same problem.

  1. Issue echo "source ~/.bashrc" >> ~/.bash_profile on your terminal to include source ~/.bashrc in your ~/.bash_profile file.
  2. Restart terminal.

Source: http://apple.stackexchange.com/questions/12993/why-doesnt-bashrc-run-automatically#comment13715_13019

same issue on M1, adding anything to ~/.zshrc didn’t resolve

admin@Peters-MacBook-Air ~ % chruby          
zsh: command not found: chruby

admin@Peters-MacBook-Air ~ % brew info chruby
==> chruby: stable 0.3.9 (bottled), HEAD
Ruby environment tool
https://github.com/postmodern/chruby#readme
/opt/homebrew/Cellar/chruby/0.3.9 (12 files, 51.2KB) *
  Poured from bottle using the formulae.brew.sh API on 2023-05-03 at 13:37:34
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/chruby.rb
License: MIT
==> Options
--HEAD
	Install HEAD version
==> Caveats
Add the following to the ~/.bash_profile or ~/.zshrc file:
  source /opt/homebrew/opt/chruby/share/chruby/chruby.sh

To enable auto-switching of Rubies specified by .ruby-version files,
add the following to ~/.bash_profile or ~/.zshrc:
  source /opt/homebrew/opt/chruby/share/chruby/auto.sh
==> Analytics
install: 223 (30 days), 5,857 (90 days), 66,886 (365 days)
install-on-request: 222 (30 days), 5,845 (90 days), 66,719 (365 days)
build-error: 0 (30 days)

nano ~/.zshrc

source /opt/homebrew/opt/chruby/share/chruby/chruby.sh
source /opt/homebrew/opt/chruby/share/chruby/auto.sh

I needed to add the following to my ~/.bashrc

. /usr/local/opt/chruby/share/chruby/chruby.sh
. /usr/local/opt/chruby/share/chruby/auto.sh

Hey devs, just adding this for completion sake if you’re using zsh as your shell and you have the same “chruby: command not found” error.

# Add the following to the ~/.bash_profile or ~/.zshrc file:
source $(brew --prefix)/opt/chruby/share/chruby/chruby.sh

reference: https://formulae.brew.sh/formula/chruby

I installed using brew but I use zsh. I had to use brew info chruby to see the installed directory. For me it was here: /opt/homebrew/opt/chruby/share/chruby/chruby.sh Thus I added source /opt/homebrew/opt/chruby/share/chruby/chruby.sh to my ~/.zshrc and it worked.

Same as @Sihui it did fix it for me after I guess the only difference was using source instead of .

# chruby
source /usr/local/opt/chruby/share/chruby/chruby.sh
source /usr/local/opt/chruby/share/chruby/auto.sh
chruby ruby-3.1.2

Even after install (0.3.9 or HEAD at 4c46722) I didn’t have a ~/.bashrc .

I had to

add: . /usr/local/opt/chruby/share/chruby/chruby.sh

and then source ~/.bashrc in ~/.bash_profile

On a brand new High Sierra 10.13.4 mbp.

If you could suggest some better post-install instructions for the homebrew recipe, please do.