18

I am looking for a path of where ruby gets stored on mac?

I installed macruby on my mac and I am trying to see where it got installed. I want to include the path of macruby in my ruby script. When I do rvm list, I get:

=> macruby-0.12 [ i686 ]
 * ruby-1.9.3-p545 [ x86_64 ]
   ruby-2.1.1 [ x86_64 ]
   ruby-2.1.2 [ x86_64 ]
   ruby-2.1.2-version [ x86_64 ]

I use #!/usr/local/bin/macruby in my ruby script, but looks like macruby is not present in that location. When I execute "whereis ruby" command on I get back "/usr/bin/ruby", but when I execute "whereis ruby-1.9.3-p545" or "whereis macruby-0.12" I get nothing.

How do I find the path of where does all these ruby versions lie?

tech_human
  • 6,592
  • 16
  • 65
  • 107

2 Answers2

28

You can get the path to the local executable with

$ which ruby

the rvm rubies are in your rvm directory, which I believe is ~/.rvm/rubies (I use rbenv so not sure about the details)

The which command should pickup whatever shims/other magic RVM is using to set your shell ruby

Kristijan Iliev
  • 4,901
  • 10
  • 28
  • 47
John Paul Ashenfelter
  • 3,135
  • 1
  • 22
  • 29
6

You can find your answer by running one of the following commands:

 which ruby
 whereis ruby 
 type -P ruby
Sergio Tulentsev
  • 226,338
  • 43
  • 373
  • 367
Hoa Hoang
  • 1,212
  • 14
  • 20
  • that will only tell somebody if they already have ruby installed – barlop Mar 21 '19 at 11:53
  • `which ruby` and `type -P ruby` >> `/Users/me/.rubies/ruby-2.6.2/bin/ruby` give the location of the currently activated Ruby, at least on my High Sierra macOS using chruby. `whereis ruby` >> `/usr/bin/ruby` gives the location of the system Ruby. My testing conditions were `chruby ruby-2.6.2`. – Greg Jun 13 '19 at 15:53