How to setup chruby for fish shell instead of regular bash/zsh

I did install chruby using brew which is easily done. However, I cant/fail to input

echo "source $(brew --prefix)/opt/chruby/share/chruby/chruby.sh" >> ~/.zshrc
echo "source $(brew --prefix)/opt/chruby/share/chruby/auto.sh" >> ~/.zshrc
echo "chruby ruby-3.1.1" >> ~/.zshrc

and keep on getting an error. I believe this need to be implemented on fish.config ?

Anyone can help?

I just ran into the same issue. Here’s how to solve it:

You have to change things around a bit for Fish. First, you can’t use chruby from homebrew, because it uses .sh scripts which don’t play nice inside config.fish. This is what you need to do:

brew install chruby-fish ruby-install

echo "source "(brew --prefix)"/Cellar/chruby-fish/0.8.2/share/chruby/chruby.fish" >> ~/.config/fish/config.fish
echo "source "(brew --prefix)"/Cellar/chruby-fish/0.8.2/share/chruby/auto.fish" >> ~/.config/fish/config.fish
echo "chruby ruby-3.1.2" >> ~/.config/fish/config.fish

source ~/.config/fish/config.fish

NOTE: The version of Ruby is newer than that’s in the Jekyll docs. The one that homebrew installed for me was 3.1.2. You can find out for sure by running chruby.