I have gone about the recommended way of installing a new version of Ruby on Mac OS X: Homebrew, and rvm. I ran rbenv to install Ruby 2.3.3, and selected it as the preferred version by using "rbenv global 2.3.3". The problem I am having is that there is currently a 2.0.0 version installed at /usr/bin/ruby, and for some crazy reason I am unable to remove it.
$ rbenv global
2.3.3
$ which ruby
/usr/bin/ruby
$ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
$ ~/.rbenv/versions/2.3.3/bin/ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
sudo rm -rf /usr/bin/ruby
Password:
rm: /usr/bin/ruby: Operation not permitted
Argh!! Please help.
The problem is not your system Ruby, the problem is you probably didn't follow the rbenv installation instructions completely correctly.
The reason the system Ruby is located before your rbenv Ruby, is because your PATH has not been properly updated.
This explains why that is important:
https://github.com/rbenv/rbenv#understanding-path
To set up your PATH correctly you can read and complete steps 2-4 here:
https://github.com/rbenv/rbenv#basic-github-checkout
Related
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.
I have the following environment setup
OS: macOS Catalina 10.15.7
Zsh: 5.8
Neovim: 0.4.4
rbenv: 1.1.2
$ rbenv local
2.7.1
$ rbenv global
2.7.1
$ /usr/bin/ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
RBENV_VERSION is not set. rbenv-doctor script also fine. Above all the facts, I assumed my rbenv setup is working.
When I am in neovim,
:echo has('ruby')
1
:ruby puts RUBY_VERSION
2.6.3
It should have been 2.7.1 but 2.6.3 (system ruby provided by macOS)
I have started with nvim -u NORC and still getting the same.
What should I check next to make NeoVim picks up rbenv specified ruby?
It cannot be reproduced in another (clean) account.
It was caused by messed up rbenv environment.
rudimentary neovim-ruby-host remained in old ruby version (found out by rbenv whence neovim-ruby-host showing unused ruby version)
rbenv shim (specifically gem) using system provided gem. (rmed the shims and rbenv rehashed)
rbenv doctor was not enough for the troubleshooting. The followings helped me find the cause
gem env and gem env home: showed I was using system provided gem executable
rbenv rehash: removed the staled shims and recreated them
rbenv which neovim-ruby-host: showed actual path of neovim-ruby-host
rbenv whence neovim-ruby-host: showed ruby versions providing the command (in my case incorrect one)
My computer came with Ruby 1.8.7 installed by default. I installed Homebrew and then used it to install the latest version of ruby. When I run the following commands, I get differing responses:
brew upgrade ruby
Warning: ruby 2.6.5 is already installed and up-to-date
ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
Not only do the versions on these two disagree, but neither of them are the most recent version of Ruby (2.7). How do I make sure what version of Ruby I have installed, and use the latest version?
Note: this question isn't a duplicate of this question because brew install ruby#2.7.0 and other similar commands have no effect, and also because the main issue is with version disagreement.
My system has:
± /usr/bin/ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
± ruby --version
ruby 2.4.7p357 (2019-08-28 revision 67796) [x86_64-darwin19]
The reason for this is the order of the directories in the PATH variable. It's read left-to-right, so if you'd like to make sure homebrew's ruby takes precedence, put
/usr/local/bin as the left-most member of your PATH variable. If you need further assistance, leave a comment.
As recommended by #anothermh and #hd1, I used RVM instead of Homebrew:
Install RVM with \curl -sSL https://get.rvm.io | bash -s stable; restart your shell; install Ruby with rvm install 2.6.0 (for example).
I have serious issues with ruby on my computer. I have the system one, I have the one which can from homebrew, I have one installed as a stand alone version, and I have several installed from rbenv.
The result of which -a ruby is:
/usr/local/bin/ruby
/Users/soldenh/.rubies/ruby-2.4.1/bin/ruby
/usr/local/bin/ruby
/usr/local/bin/ruby
/usr/local/bin/ruby
/usr/bin/ruby
However, ruby -v returns:
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin17]
but Rbenv global returns:
2.4.0
and rbenv local returns:
2.1.9
there is also are also 2 brew casks installed one called:
ruby#19
and the other is called:
ruby#22
I am using the lastest mac OSX.
When I try to run a ruby command in terminal I get an error:
Ruby >= 2.1.9 required to run app (You have 2.0.0)
When I try
brew upgrade ruby
I get
Error: ruby 2.3.1 already installed
Previously I tried installing ruby with rvm
curl -sSL https://get.rvm.io | bash -s stable --ruby
Maybe I have two different versions of ruby running?
How can I get my system to use the latest version of ruby?
EDIT: Definitely two versions installed
/usr/local/bin/ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin14]
ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
My $PATH seems correct?
-bash: /usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin: No such file or directory
EDIT2 specifying the full path to the correct version of ruby:
/usr/local/bin/ruby app.rb
/usr/local/bin/ruby: No such file or directory -- app (LoadError)
In the simplest cases, you can just specify the fully-qualified PATH to your Homebrew-installed Ruby. For example:
/usr/local/bin/ruby /path/to/foo.rb
However, if you need to require gems or libraries, you need to step up your game with a Ruby version manager such as chruby, rvm, or rbenv. You should never replace the system ruby, and managing all the environments variables, gems, and so forth that Ruby needs without a version manager is outside the scope of a reasonable Stack Overflow question.
You have installed the homebrew version 2.3.1 of Ruby, but you are not using it because you haven't set your PATH correctly.
Try using the one homebrew installed for you by adding /usr/local/bin to the start of you PATH, or by running:
/usr/local/bin/ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
I guess if you use the Apple-supplied Ruby in /usr/bin you will get:
/usr/bin/ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
You should uninstall ruby from brew and just use rvm.
If you have multiple version installed than you can use rvm to make ruby 2.3.1 your default: rvm --default use 2.1.1