Repository navigation
fix: accept a FIFO .env file in dotenv run - #723
sungbin1015 wants to merge 1 commit into
Conversation
`dotenv run` guarded the path with `os.path.isfile`, so a `.env` that is a named pipe (1Password-mounted `.env`, `<(...)` process substitution) was rejected with "does not exist", while `load_dotenv` and `dotenv list`/`get` read it. Use `_is_file_or_fifo`, as `DotEnv._get_stream` and `find_dotenv` do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent Linux validation of A private subprocess matrix uses real
On unchanged base CPython 3.12.3: the repository suite passes 289 tests on the PR, versus 288 on the base. Both runs emit the same 35 warnings (Click's isolated-filesystem deprecation and IPython's temporary-directory fallback). Ruff check/format and mypy targets 3.10–3.14 pass; those mypy targets are static checks, not runs on five interpreters. The checkout is unchanged. This validates the POSIX CLI/FIFO path and environment/exit-code behavior. It does not establish compatibility with a real 1Password mount, macOS or Windows. |
Problem
dotenv runrejects a.envpath that is a FIFO, although the library (load_dotenv,dotenv_values,find_dotenv, since #586) and thelist/getsubcommands read it fine:The same happens with a named pipe created by
mkfifoand picked up as the default./.env, which is the 1Password-mounted.envcase #586 was written for:load_dotenv()works there,dotenv run -- cmddoes not.Cause
runguards the path withos.path.isfile(file)before handing it toDotEnv.DotEnv._get_streamandfind_dotenvuse_is_file_or_fifoinstead; the guard incli.pywas not updated when FIFO support was added.Fix
Use
_is_file_or_fifoin therunguard. Missing paths and directories are still rejected with the same message. No change on Windows, where_is_file_or_fifois equivalent toos.path.isfile.Tests
tests/test_fifo_dotenv.py::test_cli_run_from_fifo(Unix only, like the existing FIFO test): fails before the change with the error above, passes after.pytest: 285 passed, 4 skipped.ruff check src tests,ruff format --check src testsandmypyfor 3.10-3.14 are clean.Related work
runpath, which Support reading .env from FIFOs (Unix) #586 did not cover.src/dotenv/main.pyfor FIFOs that are not immediately readable. It does not touchcli.py, sodotenv runwould still reject a FIFO with it applied.cli.py, but for a different problem (when the default.envpath is resolved).