Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

`set_key` / `dotenv set` report a temp file path when the target's directory doesn't exist

已關閉
#710 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
78/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
python
領域
cli

研究方向

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 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

theskumar/python-dotenv 的其他 Issue

查看 theskumar/python-dotenv 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。