Ruby version not updating after install - ruby

I successfully installed ruby version to 2.7, but ruby -v doesn't want to update. See output below:
➜ ~ ruby -v
ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]
Verify that Ruby 2.7 has been installed:
➜ ~ brew install ruby#2.7
Warning: ruby#2.7 2.7.6_1 is already installed and up-to-date.
To reinstall 2.7.6_1, run:
brew reinstall ruby#2.7
What am I missing?

Type which ruby to find out where it's getting that executable from.
$ which ruby
/opt/homebrew/opt/ruby/bin/ruby
homebrew will put it in /opt/homebrew/opt/ruby/bin/ruby as shown there, but if that's not in your path then it will get the system ruby.
$ which ruby
/usr/bin/ruby
In that case you need to add the homebrew ruby bin directory to your PATH. I have this in my .bashrc:
export PATH="/opt/homebrew/opt/ruby/bin:/opt/homebrew/lib/ruby/gems/3.0.0/bin:$PATH"

Related

Cannot use RSpec (rspec: command not found)

So I installed the newest version of Ruby:
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
By following these steps:
brew install ruby
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
I needed to change the Path so that I could use the newest version of Ruby since if not, whenever I did
ruby -v
It would just take into account the default ruby version I had installed in my MAC:
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
Everything works great but I want to install RSpec, so I do:
gem install rspec
This is what I get:
Successfully installed rspec-3.10.0
Parsing documentation for rspec-3.10.0
Done installing documentation for rspec after 0 seconds
1 gem installed
But once I check the version:
rspec --version
This is what I get:
-bash: rspec: command not found
I have uninstalled ruby with brew and installed it again and restarted the terminal but to no avail...Any idea why is this happening? How can I solve it?
Thank you!
It seems that installing Ruby via Home Brew was giving some problems when trying to run RSpec so I uninstalled it and installed it again via RVM. Although, as #Mskha said, Rbenv could also be a possible option.

how to link ruby in macos catalina

Now I am using this command to install ruby:
~/Documents/GitHub/cruise-open on  main! ⌚ 17:04:27
$ brew install ruby
Warning: ruby 3.0.0_1 is already installed and up-to-date.
To reinstall 3.0.0_1, run:
brew reinstall ruby
(base)
when I check the version use this command:
~/Documents/GitHub/cruise-open on  main! ⌚ 17:06:07
$ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
(base)
how to make mac using the new version of ruby?
add path to bash_profile:
export PATH=/usr/local/Cellar/ruby/3.0.0_1/bin:$PATH:$M2_HOME/bin:$CONDA_HOME/bin
make it work:
source ~/.bash_profile

Unable to install Ruby OpenSSL

So, I just updated Ruby version on a CentOS 7 box, to allow for the use of OpenSSL, using this guide:
https://www.server-world.info/en/note?os=CentOS_7&p=ruby23
However, the version is now set to 2.3.8 as per:
$ ruby -v
ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-linux]
and:
$ which ruby
/opt/rh/rh-ruby23/root/usr/bin/ruby
$ which gem
/opt/rh/rh-ruby23/root/usr/bin/gem
BUT, gem throws the same error as before hand:
$ sudo gem install openssl
ERROR: Error installing openssl:
openssl requires Ruby version >= 2.3.0.
Any ideas?
Try installing gems without sudo. I did such test locally
$ ruby -v
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
$ sudo ruby -v
sudo: ruby: command not found
Probably your superuser env is not using the same ruby version as your current user's env.

Ruby gem show "Invalid argument" error for almost every command

I am working through NativeScript's set-up on OS X El Capitan and I am stuck at the point where I am supposed to install xcodeproj and cocoapods. Almost everything that I try to do with gem shows the same error:
$ sudo gem install xcodeproj
ERROR: While executing gem ... (Errno::EINVAL)
Invalid argument
The following commands show the same error, wether I run it with sudo or not:
$ gem update --system
$ gem update
$ gem install whatever
$ gem install cocoapods
I have the following versions:
$ ruby --version
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
$ gem --version
2.6.7
I've tried some of the help that I've found online, including reinstalling gem and ruby, restarting but nothing has helped.
I guess that I have a configuration problem with Ruby.
Any suggestions on how to troubleshoot this?
I just had a similar issue after updating everything via Homebrew.
I solved the issue by uninstalling Ruby and installing it via rbenv, then reinstalling cocoa pods.
Steps:
Uninstall ruby
brew uninstall ruby
Install rbenv and ruby-build
brew install rbenv ruby-build
You need to add Ruby to your path.
A. If Terminal is your shell.
Add eval "$(rbenv init -)" to ~/.bash_profile
B. Or if you use another shell
You can find the instruction by entering the command rbenv init NAME_OF_YOUR_SHELL.
Install Ruby
rbenv install 2.3.1
Set the Ruby version
rbenv global 2.3.1
rbenv local 2.3.1
Reinstall Cocoapods
gem install cocoapods

RVM : cannot find installed ruby

When i cd into a project with .ruby-version file i get an error about corresponding ruby version not installed.
$ cd my-app/
ruby-2.0.0p451 is not installed.
To install do: 'rvm install ruby-2.0.0p451'
I installed it with RVM and still have the error.
More info :
I have rvm installed and i got it working without problem for some time. I recently needed ruby-2.0.0p451 for a project, after installing i was able to use it :
$ ruby --version
ruby 2.0.0p451 (2014-02-24 revision 45167) [x86_64-darwin12.5.0]
But when i add a .ruby-version file it seems RVM cannot find ruby
Here is a copy of my .bashrc and bash_profile

Resources