Racket: Setting The Mac OS PATH
Racket: Setting The Mac OS PATH
Racket: Setting The Mac OS PATH
html
beautiful racket
To see the PATH on your system, open the terminal window and enter this
command (where sh$ represents the terminal prompt, which will be different
on your system):
Type return to complete the command. The result will be a list of directo-
ries separated by : that looks like this:
/usr/bin:/bin:/usr/sbin:/usr/local/bin
The exact list may be different on your system. Now try this:
This tells us that the echo command (which prints a value to the terminal)
actually invokes the program located at /bin/echo . The terminal finds this
program by looking for echo in each of the PATH directories, one of which is
/bin .
We can always invoke a command by using its full path rather than the short-
1 of 4 4/12/19, 9:27 AM
Beautiful Racket: Setting the Mac OS PATH https://beautifulracket.com/setting-the-mac-os-path.html
hand:
In this case, the terminal doesn’t look in the PATH directories for echo ,
because we’ve already provided a full path to echo .
If we enter a command name that doesn’t exist in any PATH directory, we get
an error:
sh$ racket
-bash: racket: command not found
Our goal is to add the directory containing racket to our PATH . Then the
terminal will be able to find it.
updating path
First, check that your Racket installation works by going into your new Racket
directory and launching DrRacket. If DrRacket works, then your Racket instal-
lation is sound.
Next, check that you know the full path to the bin subdirectory of your new
Racket directory. If you put this directory in Applications as recom-
mended, the path will be:
/Applications/Racket v7.2/bin
If you installed or moved it elsewhere, the path will be different. For instance,
it can be convenient to remove the version number from the name of Racket’s
installation directory, like so:
2 of 4 4/12/19, 9:27 AM
Beautiful Racket: Setting the Mac OS PATH https://beautifulracket.com/setting-the-mac-os-path.html
/Applications/Racket/bin
This way, you can update Racket in the future without changing the rest of the
configuration below.
You can test this path from the terminal: append /racket to the path and
enter it as a command. This should start Racket (include the surrounding
double quotes around the whole thing):
sh$ "/YOUR/PATH/TO/bin/racket"
Welcome to Racket v.7.2.
>
If this doesn’t work, either the path to Racket is mistyped, or there’s an error
in your Racket installation.
If it does work, type ctrl+D or (exit) to quit Racket. Next, you need to
add this path to the "/etc/paths.d" directory on your system, which
affects the system PATH variable. You can do this with the following one-line
terminal command, which will ask you for your password (again, substitute
/YOUR/PATH/TO/bin with your actual path, and include the surrounding
double quotes):
testing path
To check that your PATH has been updated correctly, open a new terminal
window and try echo $PATH again:
3 of 4 4/12/19, 9:27 AM
Beautiful Racket: Setting the Mac OS PATH https://beautifulracket.com/setting-the-mac-os-path.html
/usr/bin:/bin:/usr/sbin:/usr/local/bin:/YOUR/PATH/TO/bin
This time, you should see your Racket bin subdirectory at the end of the
PATH list of directories.
If that works, then you’re home free. Type racket and you should see some-
thing like this:
sh$ racket
Welcome to Racket v.7.2.
>
If so, all is well. The > is the command prompt for Racket. Type ctrl+D or
(exit) to quit Racket.
4 of 4 4/12/19, 9:27 AM