IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

setenv

setenv(var name: String, var value: String, overwrite: Bool = True) -> Bool

Changes or adds an environment variable.

Constraints:

The function only works on macOS or Linux and returns False otherwise.

Args:

  • name (String): The name of the environment variable.
  • value (String): The value of the environment variable.
  • overwrite (Bool): If an environment variable with the given name already exists, its value is not changed unless overwrite is True.

Returns:

Bool: False if the name is empty or contains an = character. In any other case, True is returned.