Back to Setup

Ruby

_partials/ruby.md

latest2.0 KB
Original Source

Ruby

Installation

Now, you are ready to install the latest ruby version and set it as the default version.

Run this command, it will take a while (5-10 minutes)

bash
rbenv install <RUBY_SETUP_VERSION>

Once the ruby installation is done, run this command to tell the system to use the <RUBY_SETUP_VERSION> version by default.

bash
rbenv global <RUBY_SETUP_VERSION>

Reset your terminal and check your Ruby version:

bash
exec zsh

Then run:

bash
ruby -v

:heavy_check_mark: If you see something starting with ruby <RUBY_SETUP_VERSION> then you can proceed :+1:

:x: If not, ask a teacher

Installing some gems

<details> <summary>If you are in <bold>China</bold> 🇨🇳 click here</summary>

:warning: If you are in China, you should update the way we'll install gem with the following commands.

bash
# China only!
gem sources --remove https://rubygems.org/
gem sources -a https://gems.ruby-china.com/
gem sources -l
# *** CURRENT SOURCES ***
# https://gems.ruby-china.com/
# Ruby-china.com must be in the list now
</details>

Everyone, in China or not, continue here to install gems.

In the ruby world, we call external libraries gems: they are pieces of ruby code that you can download and execute on your computer. Let's install some!

First, we'll update bundler, which is what lets us install gems:

bash
gem update bundler

In your terminal, copy-paste the following command:

bash
gem install <GEMS>

:heavy_check_mark: If you get xx gems installed, then all good :+1:

:x: If you encounter the following error:

bash
ERROR: While executing gem ... (TypeError)
incompatible marshal file format (can't be read)
format version 4.8 required; 60.33 given

Run the following command:

bash
rm -rf ~/.gemrc

Rerun the command to install the gems.

:warning: NEVER install a gem with sudo gem install! Even if you stumble upon a Stackoverflow answer (or the terminal) telling you to do so.