2

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
Community
  • 1
  • 1
Noa
  • 21
  • 1

2 Answers2

1

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
aarkerio
  • 1,638
  • 1
  • 15
  • 29
  • 1
    Thank you! I have two questions: a. Why did I need mc? Wouldn't a simple ls -a have worked? b. Removing .rvm seem to have worked, but now I get the same error trying to 'gem install bundle' or run 'bundle -v' ('which bundle' returns '/usr/local/bin/bundle'). Does it mean I didn't really removed everything and started from the top like I hoped? – Noa Mar 09 '16 at 21:43
  • 1) Seemed to me that you are kind of new on Linux, so I suggested using MC because it can show you extra information in a more visual way. But no, it's not necessary. 2) Try to avoid using "sudo" in all the rvm, ruby, gems stuff. First install rvm, rvm is NOT a gem so, "gem uninstall rvm" doesn't make sense. Then install bundle with gem. – aarkerio Mar 09 '16 at 22:28
0

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.

Stephen Grimes
  • 388
  • 1
  • 7
  • Thank you, first of all. I didn't use sudo on gem install, all commands in my question are exactly as I used them. I'm trying to delete everything and start it all over again, but the missing .rb file won't let me do that in the ways I found on other questions here. – Noa Mar 08 '16 at 14:21
  • 2nd line of your post reads `sudo gem install bundle`. Looks like you did? – Stephen Grimes Mar 08 '16 at 17:08
  • Oh, sorry, my bad... But why is that a problem? Why should 'sudo' not be used when installing things? – Noa Mar 09 '16 at 21:39