1 Ruby setup Flashcards
How do you manage multiple versions of Ruby on a local machine?
Install few versions using rvm or rbenv. Then set on of the versions as default if you want. Use needed version as local. Check version using
$ ruby -v
How do you install at least one of the following tools? (RVM, rbenv, chruby)
rbenv (MacOS, Linux)
1. Install it from the OS package manager:
Ubuntu/Debian:
$ sudo apt install rbenv
2. Set up rbenv in your shell:
$ rbenv init
3. Close your terminal window and open a new one so your changes take effect.
4. Verify that rbenv is properly set up using thisrbenv-doctorscript:
$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
5. List the available rubies:
$ rbenv install -l
6. Install Ruby:
$ rbenv install 3.0.0
7. Set the default ruby:
#global
rbenv global 3.0.0
#local
rbenv local 3.0.0
What is a.ruby-versionfile? Do we need to commit it? Why or why not?
It’s a single-line with ruby version. A file with defined version of ruby which project is written in.
Make sure to add it to your version control systems as this is part configuring the project.
We need to commit it to allow a project to be configured for automated ruby switching.
Usually, this file is used.
What is a gemset?
Gemsets are little libraries for individual projects, where each gem used in the project is stored.
You tell Ruby which gems you need for a project, and it stores them in a gemset so you can quickly switch project to project and have all the gems you need (and only the gems you need for each project).
What is a.ruby-gemsetfile? Do we need to commit it? Why or why not?
It is the name of the gemset whereall installed gems will be stored (one gemset per project)
Make sure to add it to your version control systems as this is part configuring the project.
We need to commit it to allow a project to be configured for automated ruby switching.
How do you find the directory of a specific gemset on your local machine?
$ rvm gemdir
or
gem which %gemname%
How do you change the version of Ruby being used?
Using rvm
$rvmuse 3.0
rbenv
rbenv local 3.0.0
How do you list all the installed versions of Ruby?
$ rbenv install -l
or
$ rvm list known
What is irb? How do you run it?
It’s a playground.
$ irb