On this page:
3.5.1 Program Files
3.5.2 Backup and First Change Files
3.5.3 Preference Files

3.5 DrRacket Files 🔗

3.5.1 Program Files 🔗

The standard file extension for a Racket program file is ".rkt". The extensions ".ss", ".scm", and ".sch" are also historically popular.

DrRacket’s editor can save a program file in two different formats:

3.5.2 Backup and First Change Files 🔗

Every 30 seconds, DrRacket checks each open file. If any file is modified and not saved, DrRacket saves the contents of the file in a backup file, just in case there is a power failure or some other catastrophic error. If the original file is later saved, or if the user exits DrRacket and explicitly declines to save the file, the backup file is removed. The backup file is saved in the same directory as the original file, and the back file’s name is generated from the original file’s name:

In DrRacket’s implementation, these files are called “autosave” files, not backup files.

If the definitions window is modified and there is no current file, then a backup file is written to the user’s “documents” directory. The “documents” directory is determined by (find-system-path 'doc-dir).

When DrRacket first starts up, it looks to see if there are any backup files still present and if so, offers to restore the backup files, on the assumption that DrRacket was closed unintentionally. When it restores the files, DrRacket moves the current version of the original file out of the way (adding “autorec” to the name) and the moves the backup file in place of the original file.

Separately, DrRacket creates “first change” files. When you modify an existing file in DrRacket and save it, DrRacket copies the old version of the file to a special first-change file if no such file exists. The first-change file is saved in the same directory as the original file, and the first-change file’s name is generated from the original file’s name:

3.5.3 Preference Files 🔗

On start-up, DrRacket reads configuration information from a preferences file. The name and location of the preferences file depends on the platform and user:

The expression (find-system-path 'pref-file) returns the platform- and user-specific preference file path.

A lock file is used while modifying the preferences file, and it is created in the same directory as the preferences file. On Windows, the lock file is named "_LOCKracket-prefs.rktd"; on Unix, it is ".LOCK.racket-prefs.rktd"; on Mac OS, it is ".LOCK.org.racket-lang.prefs.rktd".

If the user-specific preferences file does not exist, and the file "racket-prefs.rktd" in the "defaults" collection does exist, then it is used for the initial preference settings. (See Libraries and Collections for more information about collections.) This file thus allows site-specific configuration for preference defaults. To set up such a configuration, start DrRacket and configure the preferences to your liking. Then, exit DrRacket and copy your preferences file into the "defaults" collection as "racket-prefs.rktd". Afterward, users who have no preference settings already will get the preference settings that you chose.