9/19/2023 0 Comments Rvm manage multiple ruby versionsNavigate to the root folder of your Ruby or Ruby on Rails project in the terminal.īefore you type in the command below, make sure you install the ruby version you want to use (2.6.6) with RVM and you create a gemset called chat_app. If you close the terminal and reopen it again, your default selections will be lost because you changed your terminal session. ![]() Let’s switch over: rvm gemset use chat_app.Ĭonfirm the switch by running rvm gemset list. Note that it’s still using the default gemset. # ruby-2.6.6 - #gemset created gemset list # note that chat_app was added to the gemset list. Let’s view the current list of RVM gemsets: That means each project has a clean isolated container (gemset) for its gems. I now use a separate gemset for separate Ruby and Ruby on Rails projects. The structure loosely represents the diagram above. Take a look at the hidden RVM folder that contains these ruby versions and gemsets on your MacOS system under. It’s also why I got a gem error when running a Ruby on Rails project that my colleagues didn’t get. This is what I DIDN’T do for my projects when I started using RVM. A Ruby version has gemsets that contain gems. The beauty of this is that you can isolate gems for different projects and avoid potential conflicts. GemsetsĪ Ruby version used through RVM can have multiple gemsets. You’re probably thinking, this is going to be a pain to manually switch Ruby versions every time in a new terminal.ĭon’t worry, I’ll show you how RVM can do that for you automatically.īefore we get there though, let’s talk about gemsets. Run rvm list and you’ll see it switches to 2.6.6! You can manually switch the ruby version by typing in: rvm use ruby-2.6.6. RVM is back to using the default ruby-3.0.0. Try to open another terminal window and run rvm list. When RVM downloaded ruby-2.6.6, it set it as the current Ruby for this terminal session. Open it up and add these two lines to it and save. If you’re running a bash terminal, navigate to the folder that has the. On MacOS, you want RVM to load whenever you start your terminal. You’ll get an error: rvm: command not found. Open your terminal and run:Įxit your terminal and enter it again. It would be even better if your machine could switch versions automatically for you. Wouldn’t it be nice if you could install multiple versions of Ruby on your machine and simply switch between them? So what do you do? You uninstall Ruby 1.9 and install 2.3. You’ll see errors if you run the 2.3 project with Ruby 1.9 Later, you download a project that requires Ruby 2.3. The problem is that there are multiple versions of Ruby that various projects use.įor example, let’s say you download and run an open source Ruby project that requires Ruby 1.9. ![]() You know that you can directly install Ruby on your MacOS or Linux system. The problem was that I installed gems from different projects into the same environment (gemset).Īlthough Bundler is smart enough to avoid gem conflicts, something still went wrong. I’m writing this post because I ran into a gem error that my colleagues weren’t running into. I use RVM daily and that’s what we’ll discuss. You have different options to choose from: RVM, rbenv, asdf. You need to use a Ruby version manager when working with Ruby and Ruby on Rails projects to avoid gem conflicts and easily switch between Ruby versions. ![]() This is the article I wish I had when I started software development with Ruby.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |