std.env
Methods for inspecting the OS process' environment.
This module provides methods for getting environment variables, the home directory, changing the working directory, etc.
Modifying variables
Modifying the current process' environment variables isn't supported, as this can introduce race conditions, or even unsound/undefined behaviour depending on the underlying platform.
Fortunately, the use-case for changing variables is rare and probably better served by using a sub process.
For more information:
- https://github.com/chronotope/chrono/issues/499
- https://github.com/rust-lang/rust/pull/24741
- https://github.com/rust-lang/rust/issues/27970
- https://github.com/rustsec/advisory-db/issues/926
Constants
ABI | The ABI of the operating system the code is compiled for. | |
ARCH | The architecture of the CPU the code is compiled for. | |
OS | The operating system the code is compiled for. |
Methods
arguments | Returns an | |
executable | Returns the path to the current executable. | |
home_directory | Returns the path to the current user's home directory. | |
opt | Returns an optional value of an environment variable. | |
temporary_directory | Returns the path to the temporary directory. | |
variables | Returns all defined environment variables and their values. | |
working_directory | Returns the current working directory. | |
working_directory= | Changes the current working directory to the given directory. |