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.
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.
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).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With