You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for .env and custom env files in uv run (#8263)
I have been reading discussion #1384 about .env and how to include it in
the `uv run` command.
I have always wanted to include this possibility in `uv`, so I was
interested in the latest changes. Following @charliermarsh's [advice
](#1384 (comment)) I
have tried to respect the philosophy that `uv run` uses the default
`.env` and this can be discarded or changed via terminal or environment
variables.
The behaviour is as follows:
- `uv run file.py` executes file.py using the `.env` (if it exists).
- `uv run --env-file .env.development file.py` uses the
`.env.development` file to load the variables and then runs file.py. In
this case the program fails if the file does not exist.
- `uv run --no-env-file file.py` skips reading the `.env` file.
Equivalently, I have included the `UV_ENV_FILE` and `UV_NO_ENV_FILE`
environment variables.
I haven't got into including automated tests, I would need help with
this.
I have tried the above commands, with a python script that prints
environment variables.
---------
Co-authored-by: Charlie Marsh <[email protected]>
0 commit comments