Install rvm Ruby on Rails and Ruby on Kali Linux

It’s not as simple as described on the rvm website. By some reason it’s just does not work on Kali Linux.

1. Clean up your system first

$apt-get autoremove

2.whereis ruby – we will install a new version and overwrite the existing version instead of removing it.

ruby: /usr/bin/ruby /usr/lib/ruby /usr/bin/X11/ruby /usr/share/man/man1/ruby.1.gz

If you still want to remove it by any reason then you can use these commands if you want but it’s not recommended ;). Try do $apt-get remove ruby

If ruby are installed from source then you need to do the following to remove them.

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

3. apt-get install build-essential zlib1g zlib1g-dev libreadline6 libreadline6-dev libssl-dev

This is for root user installation.

$\curl -L https://get.rvm.io | bash -s -- --ignore-dotfiles --autolibs=0 --ruby

Searching for binary rubies, this might take some time.
No binary rubies available for: debian/Kali_Linux_1/x86_64/ruby-2.1.0.
Continuing with compilation. Please read ‘rvm help mount’ to get more information on binary rubies.
Installing Ruby from source to: /home/ami/.rvm/rubies/ruby-2.1.0, this may take a while depending on your cpu(s)…
ruby-2.1.0 – #downloading ruby-2.1.0, this may take a while depending on your connection…
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100 11.4M  100 11.4M    0     0   397k      0  0:00:29  0:00:29 –:–:–  968k
ruby-2.1.0 – #extracting ruby-2.1.0 to /home/ami/.rvm/src/ruby-2.1.0.
ruby-2.1.0 – #applying patch /home/ami/.rvm/patches/ruby/2.1.0/changeset_r44327.diff.
ruby-2.1.0 – #applying patch /home/ami/.rvm/patches/ruby/GH-488.patch.
ruby-2.1.0 – #configuring…………………………………………….
ruby-2.1.0 – #post-configuration.
ruby-2.1.0 – #compiling…………………………………………………………………………..
ruby-2.1.0 – #installing……………………………
ruby-2.1.0 – #making binaries executable.
ruby-2.1.0 – #downloading rubygems-2.2.2
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100  404k  100  404k    0     0   707k      0 –:–:– –:–:– –:–:–  884k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.1.0 – #extracting rubygems-2.2.2.
ruby-2.1.0 – #removing old rubygems.
ruby-2.1.0 – #installing rubygems-2.2.2……………
ruby-2.1.0 – #gemset created /home/ami/.rvm/gems/ruby-2.1.0@global
ruby-2.1.0 – #importing gemset /home/ami/.rvm/gemsets/global.gems

This will install latest ruby 2.1.0 in writing this post.

root@amiOs:/home/ami# source /etc/profile.d/rvm.sh
root@amiOs:/home/ami# type rvm | head -n 1
rvm is a function

Yes it’s installed correctly!

This is quite important

root@amiOs:/home/ami# ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]

Ruby is now also installed to the correct version.

Now switch to global and update your gems.

root@amiOs:/home/ami# rvm gemset use global
Using ruby-2.1.0 with gemset global
root@amiOs:/home/ami# gem outdated
bigdecimal (1.2.3 < 1.2.5)
minitest (4.7.5 < 5.2.2)
psych (2.0.2 < 2.0.4)
rake (10.1.0 < 10.1.1)
rdoc (4.1.0 < 4.1.1)
test-unit (2.1.0.0 < 2.5.5)
root@amiOs:/home/ami# gem update

Updating installed gems
Updating installed gems
Updating bigdecimal
Fetching: bigdecimal-1.2.5.gem (100%)
Building native extensions.  This could take a while…
Successfully installed bigdecimal-1.2.5
Parsing documentation for bigdecimal-1.2.5
Installing ri documentation for bigdecimal-1.2.5
Installing darkfish documentation for bigdecimal-1.2.5
Done installing documentation for bigdecimal after 1 seconds
………….

$echo “gem: –no-document” >> ~/.gemrc

This is to speed up gem installation as we don’t need docs files.

We will create a gemset now.

root@amios:/home/ami# rvm use ruby-2.1.0@rails4.0 –create (two dashes this need to be –create instead of -create)

It’s time to install Rails

root@amiOs:/home/ami# gem install rails
Fetching: atomic-1.1.14.gem (100%)
Building native extensions.  This could take a while…
Successfully installed atomic-1.1.14
Fetching: thread_safe-0.1.3.gem (100%)
Successfully installed thread_safe-0.1.3
Fetching: tzinfo-0.3.38.gem (100%)
Successfully installed tzinfo-0.3.38
Fetching: multi_json-1.8.4.gem (100%)
Successfully installed multi_json-1.8.4
Fetching: i18n-0.6.9.gem (100%)
Successfully installed i18n-0.6.9
Fetching: activesupport-4.0.2.gem (100%)
Successfully installed activesupport-4.0.2
Fetching: erubis-2.7.0.gem (100%)
Successfully installed erubis-2.7.0
Fetching: rack-1.5.2.gem (100%)
Successfully installed rack-1.5.2
Fetching: rack-test-0.6.2.gem (100%)
Successfully installed rack-test-0.6.2
Fetching: builder-3.1.4.gem (100%)
Successfully installed builder-3.1.4
Fetching: actionpack-4.0.2.gem (100%)
Successfully installed actionpack-4.0.2
Fetching: activerecord-deprecated_finders-1.0.3.gem (100%)
Successfully installed activerecord-deprecated_finders-1.0.3
Fetching: arel-4.0.2.gem (100%)
Successfully installed arel-4.0.2

after 658 seconds
27 gems installed
root@amiOs:/home/ami# rails
Usage:
rails new APP_PATH [options]

root@amiOs:/home/ami# rvm gemset list

gemsets for ruby-2.1.0 (found in /home/ami/.rvm/gems/ruby-2.1.0)
(default)
global
=> rails4.0

root@amiOs:/home/ami# rvm gemset use rails4.0
Using ruby-2.1.0 with gemset rails4.0
root@amiOs:/home/ami#

Well done to you?

Think I can improve it? Post your comments!

SSD Hosting for 5 dollars a month https://www.digitalocean.com/?refcode=71a52388956e

34 thoughts on “Install rvm Ruby on Rails and Ruby on Kali Linux

  1. Why when i turn off my pc and i turn on this when i put on the terminal
    rails
    appears this message
    bash: rails: no se encontró la orden

    • install rails again using ( $gem install rails)
      $rails new app
      $cd app
      $bundle lock –add-platform x86-mingw32 x86-mswin32 x64-mingw32 java

      Do this .. it will work next time when you close and open up in a new terminal.

  2. Is your rvm installed corectly?
    have u try to type the below?
    type rvm | head -n 1

    This should display the following
    rvm is a function

    If it is not displaying then you may check the rvm website for correct installation and it seems you will need add a line to your bashrc so the rvm is loaded during system startup

  3. Hi everything seemed to go smooth but if i restart or exit it seems to disapeer no ruby or rails can u help pls.

    • What about this .
      have u tried source it after reboot and see id rvm is loaded.

      This seems to be rvm not loading into shell after reboot
      home/ami# source /etc/profile.d/rvm.sh
      root@amiOs:/home/ami# type rvm | head -n 1
      rvm is a function

  4. hi thabks for the fast reply the two command do work but i have to use them everytime i open a bash window. Is there a way to make to perminent.? thanks

    • easiest way would be include this “source /etc/profile.d/rvm.sh” into your .bash_profile . This can be found in your home directory

  5. hi that worked a treat thanks for ur help. Great tutorial by the way im a noob to kali and managed fine thanks again.

  6. I am having trouble as i keep getting an error

    ruby-2.2.2 – #compiling………………………………………………………………..
    Error running ‘__rvm_make -j2′,
    showing last 15 lines of /usr/local/rvm/log/1429924406_ruby-2.2.2/make.log
    compiling ossl_ns_spki.c
    linking shared-object openssl.so
    linking shared-object readline.so
    /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libncurses.a(lib_termcap.o): relocation R_X86_64_32 against `_nc_globals’ can not be used when making a shared object; recompile with -fPIC
    /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libncurses.a: could not read symbols: Bad value
    collect2: error: ld returned 1 exit status
    make[2]: *** [../../.ext/x86_64-linux/readline.so] Error 1
    make[2]: Leaving directory `/usr/local/rvm/src/ruby-2.2.2/ext/readline’
    make[1]: *** [ext/readline/all] Error 2
    make[1]: *** Waiting for unfinished jobs….
    installing default openssl libraries
    make[2]: Leaving directory `/usr/local/rvm/src/ruby-2.2.2/ext/openssl’
    make[1]: Leaving directory `/usr/local/rvm/src/ruby-2.2.2′
    make: *** [build-ext] Error 2
    ++ /scripts/functions/support : __rvm_make() 383 > return 2
    There has been an error while running make. Halting the installation.

    Any help would be appreciated.

  7. This was very helpful, thanks! Oh, the one snag I hit was this command, which needs to be space dash dash create, like this, rvm use ruby-2.1.0@rails4.0 –create … I am new to linux, so, this wasn’t immediately obvious.

  8. Hey ! Nice guide there, will be donating soon !
    Btw, i wanted to know about the DEPRECATION WARNING, it goea like this:
    DEPRECATION WARNING: Support for Rails < 4.1.0 will be dropped. (called from at /opt/metasploit/apps/pro/ui/lib/metasploit/pro/ui.rb:16)

    I get this everytime i run msfconsole on my kali linux, can u please tell me the problem and how to fix this ?!

    • Have you tried update your Rails to latest version which is 4.2 at the moment to have this info not displayed? Probably that will be the easiest way to get rid of it as long as the rails version is checked when the file executed 🙂

  9. aMi: this is about the only page online that has ruby, rvm and rails all good to go whether on arch, debian etc.
    very good job, thank you, kind regards, k1blz

  10. Installation works fine.

    But when i restart my machine and run
    ruby -v
    i get
    bash: ruby: command not found
    Seems a path to be added on reboot.
    How???

  11. Looking to Question by @tooter and perfect reply from @aMiGa….
    I had a query and searched for HOW TO INCLUDE THAT LINE TO .bash_profile to make it work permanently.

    So, here is the trick;
    echo ‘source /etc/profile.d/rvm.sh’ >>~/.bash_profile

  12. Everything was working fine until i Inputted the ‘gem outdated’ command, this is what i get
    root@kali:~# gem outdated
    ERROR: While executing gem … (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

    And I have already installed openSSl

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.