Env.aspect_cli_version
Returns the version of the Aspect CLI.
Env.current_dir
Returns the current working directory as a path.
Platform-specific behavior
This function currently corresponds to the
getcwd function on Unix
and the GetCurrentDirectoryW function on Windows.
Errors
Fails if the current working directory value is invalid.
Possible cases:
- Current directory does not exist.
- There are insufficient permissions to access the current directory.
Env.current_exe
Env.home_dir
Returns the path of the current user’s home directory if known.
This may return
None if getting the directory fails or if the platform does not have user home directories.
For storing user data and configuration it is often preferable to use more specific directories.
For example, XDG Base Directories on Unix or the LOCALAPPDATA and APPDATA environment variables on Windows.
Unix
- Returns the value of the ‘HOME’ environment variable if it is set (including to an empty string).
- Otherwise, it tries to determine the home directory by invoking the
getpwuid_rfunction using the UID of the current user. An empty home directory field returned from thegetpwuid_rfunction is considered to be a valid value. - Returns
Noneif the current user has no entry in the /etc/passwd file.
- Returns the value of the ‘USERPROFILE’ environment variable if it is set, and is not an empty string.
- Otherwise,
GetUserProfileDirectoryis used to return the path. This may change in the future.
None.
Env.root_dir
Returns the project root directory.
This project root directory is found starting at current working directory and searching upwards
through its ancestors for repository boundary marker files (such as
MODULE.aspect, MODULE.bazel,
MODULE.bazel.lock, REPO.bazel, WORKSPACE, or WORKSPACE.bazel). The first ancestor directory
containing any of these files is considered the project root. If no such directory is found, the
current directory is used as the project root.
Env.temp_dir
Returns the path of a temporary directory.
The temporary directory may be shared among users, or between processes
with different privileges; thus, the creation of any files or directories
in the temporary directory must use a secure method to create a uniquely
named file. Creating a file or directory with a fixed or predictable name
may result in “insecure temporary file” security vulnerabilities. Consider
using a crate that securely creates temporary files or directories.
Note that the returned value may be a symbolic link, not a directory.
Platform-specific behavior
On Unix, returns the value of the
TMPDIR environment variable if it is
set, otherwise the value is OS-specific:
- On Darwin-based OSes (macOS, iOS, etc) it returns the directory provided
by
confstr(_CS_DARWIN_USER_TEMP_DIR, ...), as recommended by Apple’s security guidelines. - On all other unix-based OSes, it returns
/tmp.
GetTempPath2 /
GetTempPath, which this function uses internally.
Env.var
Fetches the environment variable key from the current process.
Env.vars
Returns an iterator of (variable, value) pairs of strings, for all the environment variables of the current process.
The returned iterator contains a snapshot of the process’s environment
variables at the time of this invocation. Modifications to environment
variables afterwards will not be reflected in the returned iterator.

