Get a specific environment variable
@eryx/os Module
Summary
Functions
API Reference
Functions
os.getenv
Parameters
Environment variable name.
Returns
Environment variable value, or nil when undefined.
os.setenv
Set or unset a specific environment variable
Parameters
os.environ
Get all currently defined environment variables.
Returns
os.luauVersion
Get the git hash of Luau
There are no official "proper" version numbers for Luau, so the values here are derived from git.
The hash is the most reliable value, and indicates the exact version of Luau compiled against
The release is based on most recent tag, and typically follows the format 0.xxx, but can include
additional information if the tagged commit is not the most recent
os.platform
Get the current system platform.
Returns
Current platform identifier.
os.arch
Get the current system architecture.
Returns
Current CPU architecture identifier.
os.hostname
Get the current system hostname.
Returns
Hostname reported by the operating system.
os.tmpdir
Get the current user's temporary directory.
Returns
Absolute path to the temp directory.
os.homedir
Get the current user's home directory.
Returns
Absolute path to the home/profile directory.
os.cpucount
Get the number of CPUs present.
Returns
Number of logical CPUs.
os.totalmem
Get the total system memory in KiB.
Returns
Total memory in kibibytes.
os.freemem
Get the free system memory in KiB.
Returns
Free memory in kibibytes.
os.uptime
Get the system uptime in seconds.
Returns
Seconds since system boot.
os.uid
Current process user identifier (uid on POSIX, SID string on Windows).
Returns
Current user identifier.
os.gid
Current process group identifier (gid on POSIX, SID string on Windows).
Returns
Current group identifier.
os.euid
Effective user identifier (euid on POSIX, SID string on Windows).
Returns
Effective user identifier.
os.egid
Effective group identifier (egid on POSIX, SID string on Windows).
Returns
Effective group identifier.
os.userInfo
Resolve user details for current user or an explicit subject.
Parameters
Optional uid/SID or user name. Defaults to current user.
Returns
Resolved user details, or nil when not found.
os.groupInfo
Resolve group details for current group or an explicit subject.
Parameters
Optional gid/SID or group name. Defaults to current group.
Returns
Resolved group details, or nil when not found.
os.exit
Exit the process with a specific status code
Parameters
Process exit code. Defaults to 0.
os.clock
Get the current monotonic system clock time in seconds.
Returns
Monotonic clock value in seconds.
os.cwd
Get the current working directory.
Returns
Absolute path to the current working directory.
os.chdir
Change the current working directory
Parameters
New working directory path.
os.cliargs
Get the command line arguments for this script.
Returns only the user-supplied arguments; the executable name, subcommand, and script path are automatically stripped.
For example, eryx run foo.luau --verbose bar returns {"--verbose", "bar"}.
Returns
Ordered list of user-supplied command-line arguments.
os.exec
⚠ Yields
Execute a child process and wait for it to complete.
This function is equivalent to using:
os.spawn(...):wait()
Parameters
Executable path or name to resolve on PATH.
Ordered argument list passed to the process.
Optional spawn configuration.
Returns
Process result containing captured output and exit code.
os.spawn
Spawn a process, returning an interactive handle to it
Use stream handles for child process stdio:
local p = os.spawn("cat")
p.stdin:write("hello\n")
p.stdin:close()
local chunk = p.stdout:read(4096)
Parameters
Executable path or name to resolve on PATH.
Ordered argument list passed to the process.
Optional spawn configuration.
Returns
Handle for interacting with the running child process.
os.shell
⚠ Yields
Run a command as if it was run on the shell.
This is similar to setting shell=true in SpawnOptions, but does not
attempt to capture input or output from the process.
SpawnOptions.shell is ignored when calling this function.
Warning
This function passes the provided argument directly to cmd.exe /C
Parameters
Command string to execute through the shell.
Optional spawn configuration.
Returns
Process exit status code.
Types
SpawnOptions
Options controlling how a child process is spawned.
Specify the directory for the child process
Run this as a shell command
Warning
This passes the provided command and arguments directly to cmd.exe /C
ExecResult
Result of os.exec(...).
Captured stdout output.
Captured stderr output.
Process exit status code.
ProcessHandle
Handle to a running child process returned by os.spawn.
Wait for the process to complete
Process ID
Process return code, if it's exited
Writable stream connected to the child process stdin.
Readable stream connected to the child process stdout.
Readable stream connected to the child process stderr.
PrincipalId
Cross-platform principal identifier.
On POSIX this is typically numeric (uid/gid), and on Windows this is typically a SID string.
PrincipalInfo
Resolved user/group metadata. Fields may vary by platform.
Canonical identifier for the principal.
Friendly account/group name when available.
Principal category.
Platform that produced this identity record.
POSIX uid when available.
POSIX gid when available.
Windows SID when available.
Home/profile directory when available.
Login shell when available (POSIX).
Windows account domain when available.
Windows account name when available.