ruby -v says no such file or directory in mac os

I had the original ruby v2.6.8 I believe on my mac os. I wanted to upgrade to ruby 3.1.2 to get access to rails.

I installed ruby via homebrew, however I decided it woud be easier to manage using rbenv. I went to uninstall ruby via homebrew, and then instaled ruby 3.1.2 with rbenv.

Now when I use the

ruby -v 
-bash: /usr/local/opt/ruby/bin/ruby: No such file or directory

using the command which ruby brings me this:

/Users/user/.rbenv/shims/ruby

So the ruby is there, and rbenv claims it installed ruby 3.1.2, but did homebrew install all of ruby including the version osx came with? Im pretty sure thats a yikes moment if it did. I also can't use any ruby commands under these circumstances so I don't really know what to do from here?

How do I get my $PATH to recognize the rbenv path to ruby as the global path? I'm on MacOs 11.3.1 BigSur if thats relevant.

1 answer

  • answered 2022-05-05 05:20 Christos-Angelos Vasilopoulos

    Follow the next steps to set up rbenv, and ruby 3.1.2.

    Step 1

    brew install rbenv
    

    Step 2 Add the following lines to your .zshrc file

    export PATH="$HOME/.rbenv/bin:$PATH"
    eval "$(rbenv init - zsh)"
    

    Step 3

    brew update && brew upgrade ruby-build
    

    Step 4

    rbenv install 3.1.2
    rbenv global 3.1.2
    

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum