On this page:
system.version
system.racket_  version
system.type
system.os
system.arch
system.word
system.host
system.target_  machine
system.Target  Machine  Symbol
system.so_  suffix
system.locale_  string_  encoding
system.language_  and_  country
system.seconds
system.milliseconds
system.exit
system.path
system.Path  Symbol
system.Path  Symbol.home_  dir
system.Path  Symbol.temp_  dir
system.Path  Symbol.pref_  dir
system.Path  Symbol.pref_  file
system.Path  Symbol.addon_  dir
system.Path  Symbol.host_  addon_  dir
system.Path  Symbol.cache_  dir
system.Path  Symbol.doc_  dir
system.Path  Symbol.desk_  dir
system.Path  Symbol.sys_  dir
system.Path  Symbol.exec_  file
system.Path  Symbol.run_  file
system.Path  Symbol.orig_  dir
0.45+9.1

14.7 System Information and Control🔗ℹ

Reports the running Rhombus version.

See rhombus/version for version-number conversion and comparison utilities.

> system.version()

"0.45"

Reports the host Racket version.

See rhombus/version for version-number conversion and comparison utilities.

> system.racket_version()

"9.1"

function

fun system.type() :: Symbol

Report the host platform’s general type: #'unix, #'windows, or #'macosx.

function

fun system.os() :: Symbol

Report the host platform’s operating system more specifically than system.type. For example, the result may be #'linux or #'freebsd instead of #'unix.

function

fun system.arch() :: Symbol

Report the host platform’s architecture. Possible results include #'x86_64, #'i386, #'aarch64, #'arm (32-bit), and #'ppc (32-bit).

function

fun system.word() :: Int

Report the word size in bits for the host platform’s architecture. Possible results currently are 32 and 64.

function

fun system.host() :: String

Reports details of the host operating system in a platform-specific format.

Reports the native compilation target machine for the host platform. Possible results include #'ta6le, #'tarm64osx, and #'ti3nt.

The system.TargetMachineSymbol annotation is satisfied by a machine type symbol that are supported as a compilation target by the host Racket system, which may include a cross-compilation target machine.

Reports a file suffix conventionally used by the host operating system for shared objects, also known as dynamically linked libraries. Possible results include #".so", #".dll", and #".dylib".

A string for the current locale’s encoding. This string is suitable for use as an encoding name with bytes.Converter.

A string to identify the current user’s language and country.

On Unix and Mac OS, the string is five characters: two lowercase ASCII letters for the language, an underscore, and two uppercase ASCII letters for the country. On Windows, the string can be arbitrarily long, but the language and country are in English (all ASCII letters or spaces) separated by an underscore.

On Unix, the result is determined by checking the LC_ALL, LC_TYPE, and LANG environment variables, in that order (and the result is used if the environment variable’s value starts with two lowercase ASCII letters, an underscore, and two uppercase ASCII letters, followed by either nothing or a period). On Windows and Mac OS, the result is determined by system calls.

The system.seconds reports the current time in seconds since the epoch, January 1, 1970 UTC, which is consistent with the filesystem.modify_seconds function’s result, for example. The system.milliseconds function reports the same time with more precision, expressed in milliseconds (including fractional milliseconds) since the epoch.

See also measure.cpu_milliseconds and measure.real_milliseconds.

function

fun system.exit(v :: Any = #true) :: Void

Calls the system exit handler, which normally exits the current process. If v is a byte, then the byte is used as the process’s exit code, otherwise 0 is used as the exit code.

Returns a system-specific path categorized by which:

  • #'home_dir: The current user’s home directory.

    On all platforms, if the PLTUSERHOME environment variable is defined as an absolute path, then the path is used as the user’s home directory.

    On Unix and Mac OS, when PLTUSERHOME does not apply, the user’s home directory is determined by expanding the path "~", which is expanded by first checking for a HOME environment variable. If none is defined, the USER and LOGNAME environment variables are consulted (in that order) to find a user name, and then system files are consulted to locate the user’s home directory.

    On Windows, when PLTUSERHOME does not apply, the user’s home directory is the user-specific profile directory as determined by the Windows registry. If the registry cannot provide a directory for some reason, the value of the USERPROFILE environment variable is used instead, as long as it refers to a directory that exists. If USERPROFILE also fails, the directory is the one specified by the HOMEDRIVE and HOMEPATH environment variables. If those environment variables are not defined, or if the indicated directory still does not exist, the directory containing the current executable is used as the home directory.

  • #'pref_dir: The platform-standard directory for storing the current user’s preferences. The preferences directory might not exist.

    On Unix, the preferences directory is normally the "racket" subdirectory of the path specified by the XDG_CONFIG_HOME environment variable, or it is ".config/racket" in the user’s home directory if XDG_CONFIG_HOME is not set to an absolute path or if PLTUSERHOME is set. Either way, if that directory does not exist but a ".racket" directory exists in the user’s home directory, then that directory is the preference directory, instead.

    On Windows, the preferences directory is "Racket" in the user’s home directory if determined by PLTUSERHOME, otherwise in the user’s application-data folder as specified by the Windows registry; the application-data folder is usually "Application Data" in the user’s profile directory.

    On Mac OS, the preferences directory is "Library/Preferences" in the user’s home directory.

  • #'pref_file: A Racket-format file that contains a symbol-keyed association list of preference values. The file’s directory path always matches the result returned for #'pref_dir. The file name is "racket-prefs.rktd" on Unix and Windows, and it is "org.racket-lang.prefs.rktd" on Mac OS. The file’s directory might not exist.

  • #'temp_dir: The platform-standard directory for storing temporary files. On Unix and Mac OS, this is the directory specified by the TMPDIR environment variable, if it is defined, otherwise it is the first path that exists among "/var/tmp", "/usr/tmp", and "/tmp". On Windows, the result is the directory specified by the TMP or TEMP environment variable, if it is defined, otherwise it is the current directory.

  • #'addon_dir: A directory for user-specific Racket configuration, packages, and extension. This directory is specified by the PLTADDONDIR environment variable, and it can be overridden by the --addon or -a command-line flag to Racket. If no environment variable or flag is specified, or if the value is not a legal path name, then this directory defaults to a platform-specific locations. The directory might not exist.

    On Unix, the default is normally the "racket" subdirectory of the path specified by XDG_DATA_HOME, or ".local/share/racket" in the user’s home directory if XDG_CONFIG_HOME is not set to an absolute path or if PLTUSERHOME is set. If that directory does not exists but a ".racket" directory exists in the user’s home directory, that the ".racket" directory path is the default, instead.

    On Windows, the default is the same as the #'pref_dir directory.

    On Mac OS, the default is "Library/Racket" within the user’s home directory.

  • #'host_addon_dir: Like #'addon_dir, but when cross-platform build mode has been selected, the result refers to a directory for the current system’s installation, instead of for the target system.

  • #'cache_dir: A directory for storing user-specific caches. The directory might not exist.

    On Unix, the cache directory is normally the "racket" subdirectory of the path specified by XDG_CACHE_HOME, or ".cache/racket" in the user’s home directory if XDG_CACHE_HOME is not set to an absolute path or if PLTUSERHOME is set. If that directory does not exist but a ".racket" directory exists in the home directory, then the ".racket" directory is the cache directory, instead.

    On Windows, the cache directory is the same as the result returned for #'addon_dir.

    On Mac OS, the cache directory is "Library/Caches/Racket" within the user’s home directory.

  • #'doc_dir: The platform-standard directory for storing the current user’s documents. On Unix, it’s the user’s home directory. On Windows, it is the user’s home directory if determined by PLTUSERHOME, otherwise it is the user’s documents folder as specified by the Windows registry; the documents folder is usually "My Documents" in the user’s home directory. On Mac OS, it’s the "Documents" directory in the user’s home directory.

  • #'desk_dir: The platform-standard directory for the current user’s desktop. On Unix, it’s the user’s home directory. On Windows, it is the user’s home directory if determined by PLTUSERHOME, otherwise it is the user’s desktop folder as specified by the Windows registry; the desktop folder is usually "Desktop" in the user’s home directory. On Mac OS, it is "Desktop" in the user’s home directory.

  • #'sys_dir: The directory containing the operating system for Windows. On Unix and Mac OS, the result is Path("/").

  • #'exec_file: The path of the Racket executable as provided by the operating system for the current invocation. For some operating systems, the path can be relative.

  • #'run_file: The path of the current executable; this may be different from result for #'exec_file because an alternate path was provided through a --name or -N command-line flag to the Racket executable, or because an embedding executable installed an alternate path.

  • #'orig_dir: The current directory at start-up, which can be useful in converting a relative-path result from system.path(#'exec_file) or system.path(#'run_file) to a complete path.