DEV Community

Cover image for Adding Ruby to System Environment
Anna Villarreal
Anna Villarreal

Posted on

Adding Ruby to System Environment

I have been learning Ruby recently in an online environment. But I wanted to try to create and run an app from my local computer, using Ruby. I recently created a simple webpage for fun. I wanted to convert it to Ruby to really solidify those skills.

I had previously never messed with environment/system variables. This morning turned out to be a little more lengthy than anticipated. After cloning the project from github and putting it on my local editor, I created a gemfile and tried to "bundle install". I was wondering why it wasn't working. I kept getting messages in the terminal:

error message

For some reason, I thought I had ruby installed on my local machine.

anime girl thinking

Turns out, I did not. Here is the can of worms. After 20 minutes of googling and this discovery, I install Ruby locally. Great. Ruby should work now, right?


Not quite. You didn't think it was that easy, right? I did! Turns out, I needed to do a few more steps. I'm going to give you the simplified version of my experience this morning. XD


After Installing Ruby

You may need to add a system environment variable manually as I did. Alright then. More uncharted territory! I learn that we can do so by accessing "Edit the system environment variables".

environment variables

We then navigate to "Path" in System Variables:

system variables

With "Path" selected we click edit and then select "New"

new variable

Then we type in the executable path:
type in path


Finding your executable path

What is an executable path, and how do we find it? In order for Ruby to work in your program, you need to tell the system where to find this information. Open up your system terminal and type in "gem environment". This will give you the pertinent info.


executable directory

Look for the little charmer called "EXECUTABLE DIRECTORY". This is the path you need in your new system variable. Mind your slashes, the system will not accept a copy-and-paste. Enter that as so:

variable added

Save everything and close. Restart your editor.



Now check that everything is properly setup:
check install

Run "bundle install" in your editor terminal, given that you already have created a gemfile and such.

bundle install

Magic! XD


walking towards light
I'm sure there is a fancy way to do this all in the terminal, alas, I am a beginner. Onward and upward!!

Top comments (4)

Collapse
 
free_programmers profile image
Free Programmers

This article is simple but very practical.
❤️👍

Collapse
 
annavi11arrea1 profile image
Anna Villarreal

Hey thank you ^.^ i appreciate that.

Collapse
 
free_programmers profile image
Free Programmers

The quality of an article depends on its author! /.:.\

Thread Thread
 
annavi11arrea1 profile image
Anna Villarreal

Facts for sure!