Day 17 : #100DaysofCode - Knowing your Ruby Version & what Errno::EADDRINUSE means is important!
Tags: ruby, codenewbie, womenintech, 100daysofcode
Published: 2020-06-18 02:47:19

Today I focused on my project and updated my code for my assessment so I do not have any "new" content for my #100DaysofCode although I did code a lot today. Instead, I wanted to write about some of the random issues I have come across while using terminal. 

I had a huge issue with running rails, but not for the reasons you may believe. I kept getting an error message when trying to run ``rails new APP_PATH``, I added my error to the following stackoverflow error:

- https://stackoverflow.com/questions/61988172/error-while-running-rails-new-app-path-or-rails-help-bootsnaploadpathcac

Then I researched like crazy:
- https://unix.stackexchange.com/questions/813/how-to-determine-where-an-environment-variable-came-from
- https://rvm.io/gemsets/deleting
- https://stackoverflow.com/questions/7905114/rails-bundle-clean
- https://stackoverflow.com/questions/61988172/error-while-running-rails-new-app-path-or-rails-help-bootsnaploadpathcac
- https://github.com/rails/rails/issues/15367
- https://github.com/Shopify/bootsnap/issues/250
- https://github.com/Shopify/bootsnap/issues/268
- https://github.com/rvm/rvm/issues/3645
- https://stackoverflow.com/questions/25389633/starting-out-with-ruby-bin-rails-no-such-file-or-directory
- https://stackoverflow.com/questions/24642895/creating-rspec-files-for-existing-model-beginner
- https://github.com/rails/rails/pull/37257
- https://github.com/algolia/jekyll-algolia/issues/131
- https://stackoverflow.com/questions/23039528/your-ruby-version-is-2-0-0-but-your-gemfile-specified-2-1-0

Long story short: The error was, I was on the wrong ruby version -_____-

If you ever have that error you should try checking what version you are using by running the following:  

```
rvm list
```

Then you can choose to use a different version with
```
rvm use 2.3.9
```

Or you can make it your default by typing
``` 
rvm --default use 2.6.3
```

I am glad I was able to learn how to check my Ruby versions and hope to save someone in the future from going down the same rabbit hole that I did. 

Another "issue" you may come across while coding is "Address already in use - bind(2) for 127.0.0.1:<b>9393</b> (Errno::EADDRINUSE)"

This usually means that the localhost that you are using is already in use. To fix this you should run the following code in your terminal:

```
lsof -wni tcp:9393
```
The <b>9393</b> comes from the 127.0.0.1:<b>9393</b> code that was given in the "error" message. So you should update it with the numbers you see on your terminal. 

If inputted correctly, you will see something similar to this:

COMMAND  <b>PID</b>     USER   FD   TYPE   DEVICE 
ruby     <b>54321</b>   user  26y   IPv4   0x33maccraf83u4934     


The <b>PID #</b> is what we care about. Enter the following code with the <b>PID #</b> 

```
kill -9 54321
```
  
That will essentially kill all terminal processes using that PID #. 

You should now be able to run on your localhost using the path you were attempting to use before.

Hope this helps. 

Song of the day:
{% soundcloud https://soundcloud.com/masegomusic/veg-out-wasting-thyme-1 %}