'I installed Ruby 2.5.0 but it's showing previous version only

I have Ruby 2.6.8p205 and I installed, 2.5.0

By command

brew install [email protected]

By default, binaries installed by gem will be placed into:

    /opt/homebrew/lib/ruby/gems/3.1.0/bin

You may want to add this to your PATH.

ruby is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have ruby first in your PATH, run:
  

    echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrc

For compilers to find ruby you may need to set:

    export LDFLAGS="-L/opt/homebrew/opt/ruby/lib"

    export CPPFLAGS="-I/opt/homebrew/opt/ruby/include"

For pkg-config to find ruby you may need to set:
  
    export PKG_CONFIG_PATH="/opt/homebrew/opt/ruby/lib/pkgconfig"

But I run

ruby -v 

It still showing

ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]


Solution 1:[1]

I would advise you to use a ruby version manager like rvm or rbenv, they will make your life so much easier.

To solve the current issue though, can you try brew link [email protected] and see if that solves the problem.

Solution 2:[2]

I would also suggest a ruby version manager, I personally use asdf, if you choose to go with asdf the commands are fairly simple.

  1. To install your desired version - asdf install ruby <version>

  2. Check to see if you're using that version ruby -v

  3. If you are not using the correct one asdf global ruby <version>

  4. Also make sure you're using the ruby in your shims with which ruby

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Brad
Solution 2 Dharman