Skip to content

smelt.os

Tier: Host — Available in every runtime, including headless mode.

Environment and system primitives: getenv, setenv, platform, cwd, pid, etc.

smelt.os.arch

fun(): string

Return the target CPU architecture as reported by std::env::consts::ARCH (e.g. "x86_64", "aarch64").

smelt.os.cwd

fun(): string?, string?

Return the current working directory as (path, nil), or (nil, err_string) on failure.

smelt.os.getenv

fun(name: string): string?

Return the value of the environment variable name, or nil if it is not set.

smelt.os.home

fun(): string?

Return the user's home directory, or nil if it cannot be determined.

smelt.os.pid

fun(): integer

Return the OS process id of the running smelt instance.

smelt.os.platform

fun(): string

Return the target operating system as reported by std::env::consts::OS (e.g. "macos", "linux").

smelt.os.set_cwd

fun(p: string): boolean, string?

Change the process working directory to p. Returns (true, nil) on success or (false, err_string) on failure.

smelt.os.setenv

fun(name: string, value: string): nil

Set the process environment variable name to value. Mutates the live process env; visible to subsequent getenv calls and child processes.

smelt.os.tempdir

fun(): string

Return the platform temporary directory path.

smelt.os.unsetenv

fun(name: string): nil

Remove the environment variable name from the process environment.