How do I get chruby in my path?

What magic must be worked in the .zshrc file to get chruby in my user path? Works like a champ on EndeavourOS that only has a .bashrc and no .zshrc. Just adding

source /usr/share/chruby/chruby.sh
source /usr/share/chruby/auto.sh

to .zshrc isn’t working.

This guide is for Mac, but ZSH works the same everywhere. Looking at your source, you forgot to call chruby with a version argument.

I added a third line with the version argument to the commands listed, pasted those rows at the bottom of .zshrc and no change.

The contents of those files are functions, they don’t go into the PATH variable.

I just installed it from the AUR, added those lines to ~/.zshrc and, as you can see below, it does source them.

% chruby -h                                                                                                                                           
usage: chruby [RUBY|VERSION|system] [RUBYOPT...]

Are you sure you’re using zsh?

echo $0

EDIT:

Have you sourced your .zshrc, or opened a new terminal?

. ~/.zshrc  # . == source

Thank you for that. Turns out I’m running bash but have a .zshrc file. I’ve sourced .bashrc, logged in and out, no joy.

I’m getting closer. I uncommented /etc/profile.d/chruby.sh and chruby is recognized but I have to source .bashrc every time I log into the computer.

The lines at the bottom of my .bashrc are

source /usr/share/chruby/chruby.sh
source /usr/share/chruby/auto.sh
RUBIES=($HOME/.rubies/*)

and I have a .ruby-version file in my home folder.

It just contains the first line you already added to your .bashrc.

Why? The .bashrc is sourced every time you open a terminal, assuming you’re using bash.

Please be more specific about what you’re doing and what the result is. Showing the commands and the output is the best way, were applicable.

My .bashrc had two or three spaces added to the end of the file name. I removed them and all is well.

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.