Reference · reference

env module

2 min read · 2026-09-02 · config-weave 0.1.0

use env reads and changes the process environment and reports who and where the process is. Changes made with set and unset affect the config-weave process and every child it spawns afterwards, including commands run through the shell module. Only path_join can fail; it returns Result[string, string]. For facts about the operating system and hardware, see the sys module.

get

rust
env::get(name: string) -> Option[string]

Reads an environment variable. It returns None when the variable is unset.

set and unset

rust
env::set(name: string, value: string)
env::unset(name: string)

set assigns a variable for this process and its children. unset removes it.

path_split and path_join

rust
env::path_split(value: string) -> List[string]
env::path_join(parts: List[string]) -> Result[string, string]

path_split splits a PATH-style list on the platform separator. path_join builds one from a list of paths, and fails when a part contains the separator.

hostname

rust
env::hostname() -> string

The hostname of this machine.

current_user and home_dir

rust
env::current_user() -> string
env::home_dir() -> string

The name of the user running the process, and that user's home directory.

is_elevated

rust
env::is_elevated() -> bool

Whether the process runs as root on Unix or as an Administrator on Windows.

rust
use env

if !env::is_elevated() { return Err("this resource needs root") }
let editor = match env::get("EDITOR") { Some(e) => e, None => "vi" }