If you attempt to run Ruby and get the above error it is because Ruby is not in your path. This can be caused by numerous reasons such as if you removed Ruby to reinstall it and you were still logged into the same shell. If this is the case you can simply log out and log back in or if you are using bash just type “bash” from the command prompt to reset the shell.
If this is not your issue it means that the “ruby” command is not in your path so it needs to be updated. To view your path issue the below command.
- echo $PATH
The above command should return something like the below.
So you need to find the location of ruby itself and then add it to the path. I suggest using “locate” or “find” to figure out where ruby is hiding and then add it to the path. The ruby command more than likely is in /usr/local/bin instead of /usr/bin if you receive the initial error above.
To add /usr/local/bin to your path if it isn’t already there use the below command. First make sure to print out the path using the above command as if you don’t add all of this to the command you issue below then you will lose the rest of the path locations.
Notice that /usr/local/bin has been added to the list of locations in the path. Once you have made the change login to another shell and make sure the PATH is correct before logging out of the current connection.