Using Ruby 2D in Replit

Hello! I started learning ruby just a few days ago as a project for my cs class in high school.
I have to use replit as my ide for the class and want to mess with Ruby 2D. Does anyone know how to install ruby 2d in my replit? I need to make sure my teacher can just “join” my replit file and run the code, without needing to download anything themself.

Welcome to the forums, @ShreyaK9!
To code in Ruby using the Replit IDE, you can fork this template and invite your teacher to the repl.

1 Like

I’ve already done this so far. I want to know how to use Ruby 2D specifically, creating graphics through Ruby. Hope you can help!

Hi @ShreyaK9 , welcome to the forums!
Try entering gem install ruby2d into the Shell.
Taken from:

Hope this helps!

Hi! I’ve tried that, and got this error. Any idea on what to do from here?

1 Like

So I got that error because I realized that Ruby2d requires Linux to install a few extra packages.

sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev

I know replit uses Nix to install packages, but I don’t know how to do this. Can anyone help?

I tried looking for Nix packages but couldn’t find one.
Also, sudo doesn’t work on Replit.

1 Like

Try adding SDL2 to your replit.nix file: