Search code examples
rubyversionprojectrbenv

How do I switch my Ruby version for a single project only?


I was reading that rbenv can be used to switch the Ruby environment for a single project only. I have Ruby 2.4 installed on my system, but I'd like to use version 2.3 for a specific project only. I thought using "rbenv local" would heal the pain but it does not ...

localhost:myproject davea$ rbenv local 2.3.0
localhost:myproject davea$ bundle install
Your Ruby version is 2.4.0, but your Gemfile specified 2.3.0
localhost:myproject davea$ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]

How do I use Ruby 2.3 for this project only?


Solution

  • rbenv local only sets a .ruby-version file in your current directory, it doesn't also load that version for you. You'll need to set it and then cd .. && cd - to have the rbenv shim pick up that version.