Installing Racket and trying out a package or a file - racket/racket GitHub Wiki

Someone handed you a Racket program, but you don't know Racket and you have no idea what to do? Read on.

If you are using Linux, or if you are comfortable with the command line, you can skip to here.

Graphical interface users

1. Installation

First, download and install Racket: https://download.racket-lang.org

Once installed, start the DrRacket IDE:

  • Windows: Click on the Windows menu and enter drracket in the search box.
  • macOS: DrRacket is in the Applications folder. Otherwise, open Spotlight (Cmd+space) and enter drracket.

2. Option 1: You were handed out a single file, say my-program.rkt

Save the file my-program.rkt somewhere in your Users directory. Then, in DrRacket, click on File | Open… and look for my-program.rkt.

Now, click on Run or press F5. If nothing happens or if you see an error in red, either you should reach out to the person who handed you the program, or, if there's a corresponding website, look for more instructions there.

If it works however, and you intend to run the program multiple times, you don't need to open DrRacket every time you want to run this program, though: Jump to these instructions.

2. Option 2: You were told to try out the package named a-cool-game (say)

Once DrRacket is started, click on File | Install package… then type in the name of the package, like a-cool-game, and click on Install. Wait for the installation to finish. Depending on the package it can take a few seconds to a few minutes.

Then click on Close.

If the package has a README, you should follow the instructions there to run it. If no instruction is given, perhaps the following will work.

In DrRacket, you should see two panels. In the top panel, type the following, replacing a-cool-game with the actual package name:

#lang racket/base
(require a-cool-game)

and click on the Run button (top right) or press F5.

If nothing happens, you'll have to look for more information on the package's website about how to use it.

If it works however, you don't need to start DrRacket each time you want to start a-cool-game. Just save what you've just typed to a file: File | Save Definitions and choose a location on your disk with a name like start-a-cool-game.rkt, then follow the instructions just below.

3. Creating an executable

In DrRacket, click on Racket | Create an executable.

  1. Choose a location on disk and a name in the field at the top. Maybe the default suits you.
  2. Check the box Launcher.
  3. Check the box racket.
  4. Click on Create.

Now open a file browser, navigate to the location of the launcher and double-click on it, and voilà!

Note: If this opens a useless black window (a 'console'), you can try selecting gracket (instead of racket) on step 3. above.

Command line users

1. Install Racket

Download Racket: https://download.racket-lang.org

Linux users:

  • The file to download is a .sh. Once downloaded, you can do sh racket-something.sh to install it, and follow the instructions. You may need sudo if you choose a Unix-style installation.
  • Ubuntu/Debian: Racket is available via the Software Center (or apt) but it may be a few version behind, so this is not really the recommended way.

2. Follow these steps to Configure Command Line for Racket.

3. Option 1: You were handed out a single file, say my-program.rkt

Save my-program.rkt somewhere in your home directory. Open a terminal, cd to the corresponding directory then enter:

racket my-program.rkt

And voilà. If it doesn't work, you should reach out to the person who handed you the file.

3. Option 2: You were told to try out the package named a-cool-game (say)

First, install the package (and its dependencies):

raco pkg install --auto --update-deps a-cool-game

Then either follow the instructions provided on the package website, or try to just run it with:

racket -l a-cool-game

And voilà.