Tuesday, November 16, 2021

[SOLVED] Ability to switch between Ruby on Rails versions, one from rbenv, other from rvm

Issue

I first used rbenv to install ruby ver 2.2 and Rails ver 4.2 on Linux CentOS 7, then used rvm to install ruby ver 2.4 and rails ver 5.2. Is there a way to switch between these easily or do they both have to be installed using the same method for this to work?


Solution

I fixed this by removing RVM and installing the newer versions with rbenv instead. Having both versions installed with the same method allowed it to be easy to switch when needed. The shims automatically use the correct Rails versions for each project respectively. As far as I can tell, the Rails versions are locked in with whichever one you started the project with. You can switch the Ruby version for each project by using:

# rbenv local 2.4.1

I chose rbenv over rvm because I read several articles of people praising rbenv's lightweight approach and ease of use over rvm.

NOTE: the "#" character is the beginning of the command line in Linux CentOS 7, NOT a character that you type in.

EDIT: Thank you guys for the recommendations, though. It got me to look more into using rbenv vs. rvm.



Answered By - Rowan A. Boat