From my Notebook >

How to Install Ruby2D in Ubuntu 18.04

So you want to install Ruby2D to make some graphics or a game? Here’s what worked for me:

In Xubuntu 18.04, install the distribution Ruby as well as other needed packages. Open a terminal and type:

sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev ruby-dev rubygems-integration

Set up Xubuntu to use the Ubuntu distribution version of Ruby for your user:

mkdir ~/.ruby

Let’s use that directory for storing gems in GEM_HOME. Then we’ll update your PATH variable to include the Ruby gem bin directory. And then we’ll reload that new information into your terminal session: Run the following commands:

echo 'export GEM_HOME=~/.ruby/' >> ~/.bashrc
echo 'export PATH="$PATH:~/.ruby/bin"' >> ~/.bashrc
source ~/.bashrc

Then install the gem:

gem install ruby2d

You should see something like this in your terminal:

Building native extensions. This could take a while...
Successfully installed ruby2d-0.9.4
Parsing documentation for ruby2d-0.9.4
Installing ri documentation for ruby2d-0.9.4
Done installing documentation for ruby2d after 0 seconds
1 gem installed

Make a new ruby file somewhere in your system. Call it `triangle.rb`:

require 'ruby2d'
set title: "Hello Triangle"
Triangle.new(
      x1: 320, y1:  50,
      x2: 540, y2: 430,
      x3: 100, y3: 430,
      color: ['red', 'green', 'blue']
    )
show

With your terminal in that folder, you can now run your script:

ruby triangle.rb

Do you see the triangle? Here’s what I see:

colored triangle on black background using Ruby2D

If you don’t see the triangle: Try googling any error messages you see along the way, because that’s what I had to do. Good luck!