Matthew Schell
Matthew Schell

Reputation: 679

How to manually install rubygems?

I'm on Kali linux and I have a script that runs gem update --system. However I get the following error:

ERROR:  Your RubyGems was installed trough APT, and upgrading it through RubyGems
itself is unsupported. If you really need the latest version of RubyGems (tip:
you usually don't), then you need to install RubyGems (and Ruby) manually,
maybe using tools like ruby-install, rvm, etc.

I have never touched Ruby in my life but I've done some research to try and solve the problem myself. I tried to download the rubygems .tgz file from this link here, extracted it with tar, and followed the only step there was, ruby setup.rb. I then tried gem update --system again but I got the same error. Then I decided to try and remove rubygems with apt like this: apt purge rubygems, but it said, NOTE: selecting 'ruby' instead of 'rubygems' and it did nothing. Then I tried to completely remove ruby with apt purge ruby but not only does it remove ruby, but other programs. Here's what apt says:

Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be REMOVED:
  bundler* libruby2.7* metasploit-framework* rake* ruby* ruby-bundler*
  ruby-dev* ruby-rubygems* ruby2.7* ruby2.7-dev*
0 upgraded, 0 newly installed, 10 to remove and 0 not upgraded.
After this operation, 423 MB disk space will be freed.
Do you want to continue? [Y/n]

I don't want to remove all versions of ruby nor do I want to remove the metasploit-framework or bundler since I might need them. To sum up, does anyone know how to manually install rubygems and get gem update --system to work?

Upvotes: 1

Views: 6229

Answers (1)

mydoghasworms
mydoghasworms

Reputation: 18591

I suggest using RVM (https://rvm.io/).

Using RVM, you can have different ruby installations, each with their own version of Ruby Gems. This is installed locally (in your home directory) and RVM manages your PATH variable so that you can switch between installations and gem sets (basically multiple local gem repositories, which is very useful for doing different projects).

I have not worked on Kali Linux, but you should be able to follow the process easily here: https://rvm.io/rvm/install

Take a few minutes to learn the RVM commands to install new Rubies and switch between them and managing gem sets. I believe it's worth it.

Upvotes: 1

Related Questions