Noa
Noa

Reputation: 21

cannot load such file -- rubygems.rb when trying to uninstall rvm

I'm kind of new to Ubuntu. I got this error when trying to install bundle:

$ sudo gem install bundle
 ⏎  <internal:gem_prelude>:1:in `require':
 ⏎  cannot load such file -- rubygems.rb (LoadError)    from
 ⏎  <internal:gem_prelude>:1:in `<compiled>'

In some similar problems, it was suggested to remove rvm and ruby completelty, so I tried following the answers here.

rvm preload worked, but when trying to gem uninstall rvm I got the same message...

$ gem uninstall rvm
 ⏎  <internal:gem_prelude>:1:in `require': cannot load such file -- > rubygems.rb (LoadError)
 ⏎  from <internal:gem_prelude>:1:in `<compiled>'

When i did ruby -v, I got:

$ ruby -v
 ⏎  The program 'ruby' can be found in the following packages:
 ⏎   * ruby
 ⏎   * ruby1.8
 ⏎  Try: sudo apt-get install <selected package>

I tried to sudo apt-get install ruby as suggested, it returned:

ruby is already the newest version.

[...]

0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

I want to clean all of the ruby-related packages from my computer and start it all anew. Can you please help me doing that?

Some more details that may help:

Before doing rvm implode, I cleaned every rvm or gem related lines from my .bashrc and .bash_profile files.

$ ls /usr/lib/ruby

and

$ ls /usr/bin/ruby

return an empty dir.

/usr/lib has no other interesting directories, but /usr/bin has:

$ ls /usr/bin
 ⏎   [...] rake rake1.9.1 rake2.2 rdoc 
 ⏎   rdoc1.9.1 rdoc2.2 ri ri1.9.1 ri2.2 ruby1.9.1 ruby2.2

/usr/local/lib also had no interesting directories, but:

$ ls /usr/local/bin
 ⏎   [...]   bundle  bundler  rake

Upvotes: 2

Views: 1013

Answers (2)

aarkerio
aarkerio

Reputation: 2364

Ruby developers usually prefer to use rvm, that implies that ruby and gems will be managed as part of rvm and you must avoid install all ruby related software with the OS tools (apt, yum, pacman, etc).

Install mc (it's helpful to learn linux) and curl:

sudo apt install mc curl && mc

In the "panel" options active the option "Show hidden files", delete your .rvm dir with F8. Leave mc and run as normal user:

$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

$ \curl -sSL https://get.rvm.io | bash -s stable

Upvotes: 1

Stephen Grimes
Stephen Grimes

Reputation: 397

When running gem install, do not use sudo.

If you want to use rvm, do not install ruby through the package manager using sudo apt-get install ruby.

Upvotes: 0

Related Questions