Manuscript Documentation
v2026.12.0

@std/os/env.ms#

Import each required symbol with import Name from "@std/os/env.ms".

arguments Function#

Returns the startup arguments the host supplied, excluding the executable path. Each call returns a new list, so changing it affects neither later calls nor the native argv.

Manuscript
fn arguments() List[String] { ... }

change_directory Function#

Changes the working directory of the whole process, affecting relative paths everywhere. A missing path returns ENOENT, a path containing NUL returns EINVAL, and a denied path returns EACCES.

Manuscript
fn change_directory(path String) Result[Void, Error] { ... }

environment Function#

Returns a new map of the process’s current environment. An entry whose name or value is not valid UTF-8 is left out.

Manuscript
fn environment() Result[Map[String, String], Error] { ... }

home_directory Function#

Returns the current user’s home directory path, from the host’s environment or account database. A path that is not valid UTF-8 returns ENOTSUP.

Manuscript
fn home_directory() Result[String, Error] { ... }

load_environment Function#

Reads KEY=value lines from the file at path and sets each variable that is not already present in the environment. Existing variables keep their values, and a later duplicate name in the file replaces the earlier one. Blank lines, # comments, an export prefix, and single-, double-, or backtick-quoted values spanning lines are accepted. The whole file is validated first, so a malformed or non-UTF-8 file returns EBADMSG and changes nothing. A file larger than max_bytes returns EOVERFLOW, and a directory returns EINVAL, as for read_file.

Manuscript
fn load_environment(path String, max_bytes Int? = null) Result[Void, Error] { ... }

set_environment Function#

Sets environment variable name for this process to value, or removes it when value is null. An empty name, or a name or value with = or NUL, returns EINVAL. The change is visible to child processes started afterwards.

Manuscript
fn set_environment(name String, value String? = null) Result[Void, Error] { ... }

which Function#

Finds the executable that running name would start, or null. A name containing a path separator is checked without searching PATH. Otherwise each directory of PATH is searched in order, skipping empty entries. Candidates are tried as given, then on Windows with each PATHEXT extension (.COM;.EXE;.BAT;.CMD when unset); environment variable names are case-insensitive there. The result is a regular file the process may execute (any regular file on Windows). It is not made absolute or canonical. Example: if path := which("git"): print(path) prints the executable found on this host.

Manuscript
fn which(name String) String? { ... }

working_directory Function#

Returns the process’s current working directory. An OS failure is returned as an Error.

Manuscript
fn working_directory() Result[String, Error] { ... }