-1

I have Ruby 2.6.8p205 and I installed, 2.5.0

By command

brew install ruby@2.5

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]
halfer
  • 19,824
  • 17
  • 99
  • 186
Sun
  • 3,444
  • 7
  • 53
  • 83
  • Have you tried to restart your shell – konsolebox Mar 17 '22 at 19:33
  • This question was confusing. You told readers "You may want to add this to your PATH" and "ruby is keg-only, which means it was not symlinked into /opt/homebrew". In fact these are items in console output that the computer was telling you, but they were (un)formatted to make it seem like you were saying them. I have tried to repair this in your post. – halfer Mar 26 '22 at 13:31
  • I was facing the same problem and resloved by following this answer. https://stackoverflow.com/a/37511503/5145150 – Ahsan Malik Nov 01 '22 at 18:40

2 Answers2

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 ruby@2.5 and see if that solves the problem.

Brad
  • 8,044
  • 10
  • 39
  • 50
0

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

Dharman
  • 30,962
  • 25
  • 85
  • 135