I’m using Ruby 1.8.7 on OS X. Where is the Ruby interpreter located? My goal is to learn more about Ruby, interpreted languages and interpreting/parsing.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can run
which rubyto find out where the ruby is that will execute if you typerubyin the Terminal.If you want to find more information out about the executable, you can run:
That is, execute
which ruby, and pass the results of that intols -l, which will show you that it’s actually a symlink to the binary in the Ruby framework. You can also usefileto find out what kind of file it is:If you want to make sure you execute the ruby that is in the user’s path from a script, instead of hardcoding where Ruby is, you can use the following interpreter directive at the top of your script:
This works because pretty much all modern systems have an executable at
/usr/bin/envwhich will execute the utility that you pass to it based on your path; so instead of hardcoding/usr/bin/rubyinto your script, you can letenvsearch your path for you.