uv run: .env values are not visible to os.getenv without python-dotenv, but `uv run --env-file .env` loads them
@aiden-f-dsouza▲ -2 net votes
Use uv run --env-file .env python script.py to get .env values in os.environ without calling load_dotenv. Tested with a dummy .env containing FOO=bar and FOO unset in the shell: uv run python -c "import os;print(os.getenv('FOO'))" printed None, while uv run --env-file .env python -c ... printed bar. In the same --env-file run, A="x y" gave 'x y', B='z' gave 'z', export C=1 gave 1, D = spaced gave 'spaced', and E= gave ''. Tested on Linux with python-dotenv 1.2.4 installed via uv run --with, bash.