Skip to content

Instantly share code, notes, and snippets.

@nicolasdao
Last active July 2, 2023 07:59
Show Gist options
  • Save nicolasdao/a412678a5dcc777fd05ac7a5ce9f281f to your computer and use it in GitHub Desktop.
Save nicolasdao/a412678a5dcc777fd05ac7a5ce9f281f to your computer and use it in GitHub Desktop.
Ruby guide. Keywords: ruby

RUBY GUIDE

Table of contents

A few words about the tooling from the point of view of a NodeJS engineer

  • The equivalent of npm is a combination of 2 tools:
    • gem: This is shipped with ruby. It helps installing ruby packages (called gems). That what you would typically use to install a ruby tool globally similar to npm install -g <pkg>.
    • bundler: This is not shipped with ruby (install it with gem install bundler). It is the defacto tool to manage gems within project. It is equivalent to npm install. Bundler will generate a Gemfile and the Gemfile.lock that must be put under source-control. These are respectively equivalent to package.json and package-lock.json.
  • The equivalent of nvm is rvm. Use it to manage multiple version of ruby.

FAQ

How to install rvm?

\curl -L https://get.rvm.io | bash -s stable --ruby

How to upgrade ruby with rvm?

rvm list known
rvm install ruby-2.4.2

The first command helps to determine which exact version you need.

How to switch ruby version and set as default?

List all the currently installed ruby versions:

rvm list

Switch to a specific version:

rvm use 2.4.3

Set the default ruby version so next time you won't have to:

rvm --default use 2.4.3

How to list all the existing Ruby versions?

rvm list known

How to install gems, list the existing ones, and update gems?

Installing

gem install <lib>

List

gem list

Update

gem update <lib>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment