Reputation: 8757
Everything was working fine , until we decided to upgrade ruby to 1.8.7 from 1.8.6, and thats when all hell broke loose. When we compiled Ruby 1.8.7 from source it got installed into /usr/local/bin and Ruby 1.8.6 stayed in /usr/bin. Currently, we've uninstalled ruby 1.8.6 and by some stroke we deleted the ruby 1.8.7 files from /usr/local.
when we try "which ruby" it points to /usr/local. If anybody could help us out what we need to do get back on track , we would be very grateful.and also any idea how we can uninstall ruby from /usr/local. we tried yum remove ruby , which removed ruby from /usr/bin.Thanks and Cheers !
Upvotes: 36
Views: 194080
Reputation: 1255
I know I'm replying a bit late, but I faced the same issue today and found a detailed explanation here that might help others :
First of all, there is a system version of Ruby at /usr/bin/ruby that is at version 2.6.10. Because there is already a system version of Ruby, doing brew install ruby or brew upgrade ruby does install a newer Ruby version but does not place it in your PATH (Homebrew calls this "keg-only" formula). That means that just typing ruby -v in your shell will still output 2.6.10, because the PATH still contains only /usr/bin/ruby. You can find what Homebrew installed for you by doing echo
brew --prefix ruby
/bin. For more information on this, you can view the output of brew info ruby.Now, if you want to use a newer version of Ruby with rbenv, you're on the right track to, but I suspect a similar PATH problem. I see you installed Ruby 3.3.1 and set it as rbenv "global" version. This is all good. But ruby -v still prints 2.6.10, which tells me that rbenv isn't properly set up in your PATH, which is likely due to the eval "$(rbenv init - zsh)" line not being in your ~/.zshrc. Make sure that that line is there and restart your terminal. Then, which ruby should show ~/.rbenv/shims/ruby instead of /usr/bin/ruby, and your rbenv global Ruby version should start to take effect.
Upvotes: 0
Reputation: 26758
sudo make uninstall
did the trick for me using the Ruby 2.4 tar from the official downloads page.
Upvotes: 1
Reputation: 9594
If ruby was installed in the following way:
./configure --prefix=/usr/local
make
sudo make install
You can uninstall it in the following way:
Check installed ruby version; lets assume 2.1.2
wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.bz2
bunzip ...
tar xfv ...
cd ruby-2.1.2
./configure --prefix=/usr/local
make
sudo checkinstall
# will build deb or rpm package and try to install it
After installation, you can now remove the package and it will remove the directories/files/etc.
sudo rpm -e ruby # or dpkg -P ruby (for Debian-like systems)
There might be some artifacts left:
Removing ruby ...
warning: while removing ruby, directory '/usr/local/lib/ruby/gems/2.1.0/gems' not empty so not removed.
...
Remove them manually.
Upvotes: 2
Reputation: 11228
Create a symlink at /usr/bin named 'ruby' and point it to the latest installed ruby.
You can use something like ln -s /usr/bin/ruby /to/the/installed/ruby/binary
Hope this helps.
Upvotes: 5
Reputation: 13105
Edit: As suggested in comments. This solution is for Linux OS. That too if you have installed ruby manually from package-manager.
If you want to have multiple ruby versions, better to have RVM. In that case you don't need to remove ruby older version.
Still if want to remove then follow the steps below:
First you should find where Ruby is:
whereis ruby
will list all the places where it exists on your system, then you can remove all them explicitly. Or you can use something like this:
rm -rf /usr/local/lib/ruby
rm -rf /usr/lib/ruby
rm -f /usr/local/bin/ruby
rm -f /usr/bin/ruby
rm -f /usr/local/bin/irb
rm -f /usr/bin/irb
rm -f /usr/local/bin/gem
rm -f /usr/bin/gem
Upvotes: 22
Reputation: 160551
It's not a good idea to uninstall 1.8.6 if it's in /usr/bin
. That is owned by the OS and is expected to be there.
If you put /usr/local/bin
in your PATH before /usr/bin
then things you have installed in /usr/local/bin
will be found before any with the same name in /usr/bin
, effectively overwriting or updating them, without actually doing so. You can still reach them by explicitly using /usr/bin
in your #! interpreter invocation line at the top of your code.
@Anurag recommended using RVM, which I'll second. I use it to manage 1.8.7 and 1.9.1 in addition to the OS's 1.8.6.
Upvotes: 24