简体   繁体   中英

How to set specific Ruby version for projects(no rvm and rbenv)

I worked on some project when in some moment I have to change Ruby version for some other project. Now when I want to go back to first project, I'm getting some errors because of Ruby version. The question is how to change Ruby version(currently I'm on RVM-installed Ruby 2.5.1) and want to back to Ruby 2.4.5 but it wasn't installed via Rvm or Rbenv, just clean installation.

I know how to change Ruby version via Rvm, but how to change to version which is not installed with any addition (Rvm or Rbenv)

Even though this doesn't answer your question directly, I would recommend against using both RVM Ruby and system Ruby together. RVM was not designed to work that way and every issue arising from this kind of installation would be quite difficult to debug, particularly if you are a beginner.

So the easiest way to go would be to remove the system Ruby completely and create a 2nd RVM gemset for your other project. (This is how RVM is intended to be used, actually.)

See doc: https://rvm.io/gemsets/creating

https://rvm.io/gemsets/basics

If you have more then one projects with different ruby versions then we need to use rvm gemsets to avoid conflicts.

Steps to be followed:

rvm gemset create sriharsh
rvm use 2.2.1@sriharsh --create
rvm gemset list (to check list of gemsets)
rvm list (list of rvm rubbies)

However, if you are using Bundler then you don't need to use RVM Gemsets. Prepending any command with bundle exec will execute it in the context of the project's Gemfile.

For ex:

bundle exec rails s

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