Search code examples
rubyterminalhomebrewjekyllchruby

Problem when trying to Install Chruby, Terminal Issue


I am trying to install and use Chruby to install Jekyll as stated in the Jekyll site. However, when I run the command

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

I get the following error:

zsh: no such file or directory: source /opt/homebrew/opt/chruby/share/chruby/chruby.sh

I am not good at all these Terminal operations, so can someone please guide me through the process or what may be going wrong step by step? Thanks.

I checked whether I had installed chruby, and it said I did. I installed everything with Homebrew and all the files installed correctly.


Solution

  • What this is saying is that the chruby command was not install properly (is in the wrong place, or not there at all). Did you run the commands the website told you to run before the source command?

    # 1. Install Brew
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 
    
    # 2. Install chruby, ruby-install, and xz
    brew install chruby ruby-install xz
    
    # 3. Install ruby through chruby
    ruby-install ruby 3.1.3
    
    # 4. Make zsh use chruby's version of ruby instead of the system version
    echo " $(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.3" >> ~/.zshrc # run 'chruby' to see actual version
    

    EDIT: Sorry, I missed that you had said you already ran these commands

    Since it seems like you did run these commands try this:

    # 1. find the chruby path. Mine, for example, is 
    # /usr/local/Cellar/chruby/0.3.9/share/chruby/chruby.sh
    find / -name "chruby.sh" 2>/dev/null
    
    # 2. find the auto.sh path. Mine is 
    /usr/local/Cellar/chruby/0.3.9/share/chruby/auto.sh
    find / -name "auto.sh" 2>/dev/null
    
    # 3. Add the source command to your zshrc file with the found paths
    echo "source {{ insert_chruby_path }}" >> ~/.zshrc
    echo "source {{ insert_auto.sh_path }}" >> ~/.zshrc
    echo "chruby {{ insert_version_number }} >> ~/.zshrc
    

    This manual approach might help you. Good luck!