Skip to content

smelt.os

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

Visibility: Public - Stable Lua API intended for user config and plugins.

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.exe_path

fun(): string?, string?

Return the filesystem path to the running smelt binary as (path, nil) on success, or (nil, err_string) on failure. Useful for plugins that re-exec the binary or report install location.

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.open_url

fun(url: string): boolean, string?

Open url in the system's default browser. Only http(s)://, mailto:, and file:// URLs are accepted. Returns (true, nil) on a successful spawn, or (false, err_string) if the scheme is rejected or every launcher errored.

smelt.os.open_url_if_available

fun(url: string): table

Open url only when the host environment can auto-open a browser. Returns { opened = bool, error = string?, reason = string? }.

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.