Reputation: 71
I broke ruby in my system by doing this:
mkdir /tmp/ruby && cd /tmp/ruby
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz
tar xfvz ruby-1.9.3-p327.tar.gz
cd ruby-1.9.3-p327
./configure
make
sudo make install
The problem occurs in many different circumstances:
Trying to acess IRB:
$ irb
<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
from <internal:gem_prelude>:1:in `<compiled>'
Trying to install gems:
$ gem install rubygems-update
<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
from <internal:gem_prelude>:1:in `<compiled>'
I tried to use synaptic to remove all ruby related packages, and reinstalled it, but it didn't solve my problem. I didn't install ruby through rvm, I used rbenv:
rbenv uninstall 2.2.3
rbenv install 2.2.3
I also tried the purge command. I don't know what's happening. I'm very desperate looking for a solution. The directory /tmp/Ruby had been deleted by me... I deleted it using thunar. Someone please help me.
Upvotes: 0
Views: 3967
Reputation: 7482
If you still have that /tmp/ruby
directory, than go there and run
$ sudo make uninstall
This command will uninstall all previously installed files from that ruby. It usually installs into /usr
directory, so if you had a system ruby (installed from Synaptic or apt-get
(it seems you're using Debian-based system such as Ubuntu) could also break your system ruby, you need to reinstall it too. You can find out it this way:
$ sudo apt-get install aptitude # install aptitude for easy searching
$ aptitude search ruby | grep ^i # find all installed packages, containing ruby in their titles
In contrast, rbenv
or rvm
don't use your system paths for installation, instead they use your home folder and install to a path like ~/.rbenv
, but since you mess up your system folder rbenv
may look to a different place (it's hard to say for sure what's going on right now).
After you've cleaned up your unwanted ruby installation, use ruby-build
to install desired ruby with rbenv
:
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build # install ruby-build
$ rbenv install -l # list available versions
$ rbenv install 2.2.3 # install desired version
I hope that helps.
Upvotes: 1
Reputation: 166
First uninstall the compiled from source version you installed:
cd /tmp/ruby
sudo make uninstall
Then purge system ruby:
sudo apt-get purge
Then install RVM, close and reopen your terminal, and do rvm install 2.2.0
Upvotes: 0