Search code examples
ruby-on-railsruby-on-rails-4rubygemsrbenvruby-on-rails-7

How to use two ruby,rails version on same machine but different project?


Right now I have a project demo on my Desktop with versions

Ruby-2.6.3p62
Rails-4.2.11.3
Gem-3.0.3

and I want to create an another project new on my Desktop with versions

ruby-3.1.1p18
Rails-7.0.2.3
Gem-3.3.13

and currently, I have this rbenv version

rbenv version
2.6.3 (set by /home/akshit/.rbenv/version)

Can you share the commands on how to create project new without affecting my project demo?


Solution

  • Using rbenv do this:

    • create project new
    • open a terminal inside root folder
    • write rbenv install 3.1.1 and then rbenv local 3.1.1 so for this project it will use the specified version

    I suggest you to create a .ruby-version file where you set the project's ruby version, in this case 3.1.1