Genadinik
Genadinik

Reputation: 18639

How do I check if RVM for Gem management in Ruby was properly installed?

Is there a command to see if RVM was probably installed? I just went through the setup process of RVM and would like to test it out.

Also, since I have (or will eventually have) RVM, should I no longer use apt-get to download libraries/gems and always do that through RVM?

Upvotes: 4

Views: 7268

Answers (3)

timurb
timurb

Reputation: 5554

There are several cases:

  • RVM is not installed
  • RVM is installed but not used (i.e. its bindir is added to PATH but it is not sourced)
  • RVM is installed and used but not loaded (i.e. it is sourced but you are checking that from a script)
  • RVM is installed and used

The only way I've found to test for all 4 cases is checking for environment variables starting with rvm_:

env | egrep -v '^PATH' | egrep '^rvm_path'

We could check for variables like MY_RUBY_HOME or GEM_HOME but these can be overriden manually by user so it does not guarantee we are using RVM.

If you are going to use the above command in script you can reword it like the following and check for exit code:

env | egrep -v '^PATH' | egrep -q '^rvm_path'

Of course if you just need to find out if RVM is there on disk and is accessible you can go with simpler ones like other suggested here.

Upvotes: 1

Michael Kohl
Michael Kohl

Reputation: 66837

First, make sure your RVM is properly installed:

https://rvm.beginrescueend.com/rvm/install/

rvm info is a good way of finding out if everything went well.

Regarding gems, I'd say manage them through the RVM-installed Rubies, they have some advantages like gemsets:

https://rvm.beginrescueend.com/gemsets/

Now I now there's always been some controversy between people who prefer native packages over gems (and there are some valid reasons for that, but this is a discussion for another time), but I think RVM tipped the scale a bit here, as do the problems with Ruby packages on Debian:

http://www.lucas-nussbaum.net/blog/?p=617

Upvotes: 2

Will Ayd
Will Ayd

Reputation: 7164

rvm -v is a good start and then per the installation instructions (link) typing in $ type rvm | head -1 should return 'rvm is a function'. as to the second part yes you should just stick to installing gems with rvm using gem install (gemname here) and that will save you a good deal of trouble

Upvotes: 8

Related Questions