Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force Ruby Version

I just got burned because I used find_index on an array on my dev box (OSX with Ruby 1.8.7) and the deployment machine runs Ruby 1.8.6. (What's the difference between find_index and index? The latter works on 1.8.7 and 1.8.6)

So that got me thinking: what's the best way to force Rails to run with a specific Ruby version?

Since it's probably relevant (install multiple rubys!), I need to know this for OSX, but it would be useful to know for Linux, Windows, and Commodore 64 as well.

Later: Of course I'm working in a virtual appliance now, but I'd like to be able to control my Ruby versions if possible on my computer.

Note: I don't care too much disallowing Rails running with the wrong Ruby version. I'm more interested in getting the RIGHT ruby version to run. Sorry for the confusion.

like image 698
Dan Rosenstark Avatar asked Jan 21 '10 00:01

Dan Rosenstark


People also ask

How do I get a specific version of Ruby?

Selecting a version of Ruby You'll need to install bundler 1.2. x or above to use the ruby keyword and bundler 1.13. x or above to use a Ruby version specifier. You can use the ruby keyword in your app's Gemfile to specify a specific version of Ruby.

What is the current Ruby version?

For running scripts, you can use the "system" Ruby comes pre-installed on macOS. Ruby 3.1. 0 is the Ruby latest version (3.1. 0 was released Dec 25, 2021).


1 Answers

This won't force the version of ruby required but you may want to utilize something like RVM to easily manage your ruby environment on your dev and production boxes.

http://rvm.io/

This allows you to easily switch and maintain multiple versions of ruby on your system.

like image 55
Jim Jeffers Avatar answered Oct 03 '22 22:10

Jim Jeffers