How to Run A Ruby File In Terminal | On A Mac

Bash: “command not found”

Where is my Ruby file and how have i forgotten how to run a .rb file in terminal already?

“What is ‘Terminal’ & why are you telling me to use it? I thought I was supposed to be using ‘Command Line’? “

Most Ruby scripts do not have graphical user interfaces then they are ran using the command line or command prompt. The command line or prompt as far as I am aware, can only be accessed though the terminal.

How To Find The Terminal On A Mac

  1. Click on the search icon on the top right hand corner of your screen. The Spotlight search bar will then appear.

Creating Your Ruby File

At this point I am going to assume you have been learning ruby so have written a few ruby documents before. However if not follow the simple steps below:

Installing Ruby To Your Mac

On a Mac Ruby should be pre-installed. Check this by typing into the terminal:

Running Your Ruby File

When you open your terminal you should find some script already there. It will most likely contain information on your computer and username then be followed with your prompt.

Getting An Error Message?

How To Stop Terminal Running Your Script

If you have gone wrong somewhere you may need to stop the terminal or go back up to where you started. You can do this simply by closing and re-opening the terminal.

--

--

Software developer: abitravers.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store