简体   繁体   中英

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

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?

Better you can use rvm. Rvm is the better tool to switch between many versions with the command

rvm use ruby-2.5.1 or rvm use 2.5.1

For list out all rvm just use

rvm list

within rvm, you can manage the versions nicely no need of rbenv here.

I prefer RVM, it's easy to switch between version, also you can use multiple rails version for that ruby easily

install rvm, install ruby and create a gemset with rvm use 2.4@rails_5_2 --create will create a gemset with name rails_5_2

for switching between versions. I use .ruby-version and .ruby-gemset files in my project so i don't need to specify version all the time

in the .ruby-version file write the ruby version

2.4

and inside ruby-gemset write gemset name

rails_5_2

so whenever you will run the project it takes ruby and rails version from there

you can create this two file manually or you can run this command in terminal from your application directory which will create this two files

rvm --ruby-version use 2.4@rails_5_2

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM