14

To explain, I have OSX and I wanted to install PLT Racket. I don't know how to use the raco command to run .rkt files in the terminal instead of using the Dr. Racket interpreter. I don't really like the DrRacket text editor.

Where do I put the bin, lib, and other folders? I can't seem to access the raco command at all or any of the other commands in the Racket bin.

Sam Tobin-Hochstadt
  • 4,983
  • 1
  • 21
  • 43
TheVerv
  • 141
  • 1
  • 3
  • If your only issue is w/ the text editor, you can use whatever editor you wish for the source files and still use the interpreter for, well, interpreting. – Scott Hunter Jan 29 '12 at 03:15
  • I figured I could do that but I wanted to learn how you could use the commands that came with Racket in the terminal. – TheVerv Jan 30 '12 at 23:43
  • I share your slight confusion. Apparently, the Mac OS X package is a DMG even though you are supposed to do a manual install to actually use it (say, have raco available). While I'm able to do a manual install, DMG means (by convention) "don't do that!" – Blaisorblade Dec 09 '12 at 21:09
  • I added a usability bug report about this: http://bugs.racket-lang.org/query/?cmd=view&pr=13356. – Blaisorblade Dec 09 '12 at 23:22

3 Answers3

21

Don't move subcomponents around. This potentially breaks Racket, which expects the bin directory to be in a certain place relative to its libraries.

Instead: add the Racket bin directory to your PATH. See Set environment variables on Mac OS X Lion or Setting environment variables in OS X? for more details on setting up environment variables in Mac OS X.

For example, I personally have Racket 5.2 under "/Applications/Racket v5.2/". I have a ~/.profile with the following contents:

mithril:~ dyoo$ cat .profile
## Adding Racket 5.2 to my PATH
export PATH=/Applications/Racket\ v5.2/bin:$PATH
## .. other contents omitted

After a re-login, I can see Racket from the Terminal:

mithril:~ dyoo$ which racket
/Applications/Racket v5.2/bin/racket

I have one additional file, the ~/.MacOSX/environment.plist, whose contents define more environment variables for graphical programs. Mine has the following contents:

mithril:~ dyoo$ cat .MacOSX/environment.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>MANPATH</key>
    <string>/usr/local/man:/usr/share/man:/usr/local/share/man:/usr/X11/man</string>

    <key>PATH</key>
    <string>/Users/dyoo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/Applications/Racket\ v5.2/bin</string>
</dict>
</plist>

Having this file lets me run Racket from graphical programs that don't inherit their environment from the .profile login file.

Community
  • 1
  • 1
dyoo
  • 11,795
  • 1
  • 34
  • 44
  • Where do you put this .plist and how would you even make one? – TheVerv Jan 30 '12 at 20:42
  • Oh that was my mistake didn't notice the link to environment variables would make sense. – TheVerv Jan 30 '12 at 22:48
  • I tried making this file and then moving into the .MacOSX folder that I created but it still doesn't work on re-login. Is there something I'm doing wrong here? I changed your username to mine, and when I type echo $PATH and echo$MANPATH it responds with the same strings that I set. However when I type in which racket nothing seems to happen and it says the command cannot be found / doesn't exist when I try to use racket example.rkt – TheVerv Jan 30 '12 at 23:35
  • Can you echo $PATH and show it to us? Also, can you confirm that you've installed Racket in your Applications directory? – dyoo Jan 31 '12 at 02:00
  • TheVerv: ping! Have you been able to get this to work, or are you still having problems? – dyoo Feb 02 '12 at 15:31
3

You can just cd into the Racket/bin directory and execute it from there (you might need to specify ./raco if . isn't in your path). Or you could specify the full path to raco (can't help you w/ that as I don't know where you installed it).

Scott Hunter
  • 48,888
  • 12
  • 60
  • 101
  • Thanks, I actually figured it out just a few minutes ago before I read this, I moved it to my bin folder and then created a path. The problem was that every guide I found was for non-bash terminals so when I found out I ended up doing as you said. – TheVerv Jan 28 '12 at 21:23
  • 1
    Ooh... don't move it! See Danny's comment. Really, putting it in your bin folder is not the way to go. – John Clements Jan 29 '12 at 02:19
2

If you just want to run a program in a .rkt file, you probably want to use the racket program instead of raco. For example, if you have hello.rkt type in racket hello.rkt, assuming it's in your path. Raco is mainly a tool for development (like creating executables). See the intro section of the Guide for more information on running programs.

Asumu Takikawa
  • 8,447
  • 1
  • 28
  • 43