`set_key` / `dotenv set` report a temp file path when the target's directory doesn't exist
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
Start in src/dotenv/main.py at rewrite(), then inspect set_value and unset in cli.py. Compare their OSError handling with stream_file’s get/list behavior. Done means library errors name the target .env path, while the CLI prints a short error and exits with code 2 for missing or unwritable parent directories.
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- Python
- 星號
- 8.9k
- 分支
- 612
- 平均合併
- 4 天 23 小時
- 30 天內合併 PR
- 4
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
theskumar/python-dotenv 的其他 Issue
-
An empty value ignores ${name:-default}可能已有人在做 @SashaMIT 於 12 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 75/100
theskumar/python-dotenv#715 ·
維護者通常 1 天內回覆
-
set_key and unset_key don't fsync before replacing the .env file可能已有人在做 @Imkkey 於 12 天前認領。 未關閉enhancement
難度 3/5 1-2 天 新手友好度 72/100
theskumar/python-dotenv#713 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 28/100
theskumar/python-dotenv#693 · 1 則留言 ·
維護者通常 1 天內回覆
-
python-dotenv installation without cli masks python-dotenv cli可能已有人在做 @gyanu2507 於 51 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 55/100
theskumar/python-dotenv#683 · 4 則留言 ·
維護者通常 1 天內回覆
-
Feature Request: Automatically copy `default.env` to `.env`可能已有人在做 @dradetsky 於 161 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 55/100
theskumar/python-dotenv#644 · 2 則留言 ·
維護者通常 1 天內回覆
查看 theskumar/python-dotenv 的全部 Issue
相似的 Issue
-
Atomic append fails to create a missing file可能已有人在做 @harbinresearcher 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 70/100
fabiocaccamo/python-fsutil#201 ·
-
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
task
難度 2/5 1-3 小時 新手友好度 78/100
danparshall/claude_researcher#87 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 62/100
GhostManager/Ghostwriter#998 · 1 則留言 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 85/100
datajoint/datajoint-python#1586 ·
維護者通常 1 天內回覆