When the parent directory of the target file doesn't exist, the error names an internal temp file instead of the .env path:
>>> dotenv.set_key("/tmp/nodir/.env", "A", "1")
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/nodir/.tmp_tjtn0_ek'
The CLI (dotenv -f /tmp/nodir/.env set A 1) prints a full traceback ending in the same message.
Cause: rewrite() in src/dotenv/main.py creates its NamedTemporaryFile in the target's directory before touching the target, so that's what fails first. set_value/unset in cli.py don't catch OSError.
Expected: the library raises an error that names the .env path. The CLI prints a short error and exits with code 2, as stream_file does for get/list. The same probably applies when the directory isn't writable.
When the parent directory of the target file doesn't exist, the error names an internal temp file instead of the
.envpath:The CLI (
dotenv -f /tmp/nodir/.env set A 1) prints a full traceback ending in the same message.Cause:
rewrite()insrc/dotenv/main.pycreates itsNamedTemporaryFilein the target's directory before touching the target, so that's what fails first.set_value/unsetincli.pydon't catchOSError.Expected: the library raises an error that names the
.envpath. The CLI prints a short error and exits with code 2, asstream_filedoes forget/list. The same probably applies when the directory isn't writable.