dotenv-cli - rewrite() does not resolve symlinks
维护者通常 1 天内回复
评估
调研方向
Start in src/dotenv/main.py at the rewrite() function and review how dotenv set and dotenv unset handle a symlinked .env path. Verify the behavior with a symlinked file on the supported platforms; done means those CLI operations update the target file as expected without breaking regular paths.
由索引模型根据 Issue 内容生成。
描述
While having a play around w/ dotenv today, I noticed that if my .env file was symlinked elsewhere, using the CLI utility via dotenv set or dotenv unset would not work as I expected it to, so I made this small change to the rewrite function:
diff --git a/src/dotenv/main.py b/src/dotenv/main.py
index 052de05..3606abe 100644
--- a/src/dotenv/main.py
+++ b/src/dotenv/main.py
@@ -132,8 +132,12 @@ def rewrite(
path: StrPath,
encoding: Optional[str],
) -> Iterator[Tuple[IO[str], IO[str]]]:
- pathlib.Path(path).touch()
+ path = pathlib.Path(path)
+ if path.is_symlink():
+ path = path.resolve()
+
+ path.touch()
with tempfile.NamedTemporaryFile(mode="w", encoding=encoding, delete=False) as dest:
error = None
try:
This does what I want, but I'm not sure if there are disadvantages to this. I know symlinks are more widely used on linux, but if I'm not mistaken I think this would work on Windows too, since dotenv works with files and not directories.
- 主要语言
- Python
- 星标
- 8.9k
- 派生
- 585
- 平均合并
- 8 天 8 小时
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
theskumar/python-dotenv 的其他 Issue
-
An empty value ignores ${name:-default}可能已有人在做 @SashaMIT 于 3 天前认领。 未关闭
难度 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 于 3 天前认领。 未关闭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可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 55/100
theskumar/python-dotenv#683 · 4 条评论 ·
维护者通常 1 天内回复
-
Feature Request: Automatically copy `default.env` to `.env`可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 55/100
theskumar/python-dotenv#644 · 2 条评论 ·
维护者通常 1 天内回复
查看 theskumar/python-dotenv 的全部 Issue
相似的 Issue
-
dead_air_detection fails on m4a/AAC audio ("Could not decode audio: Format not recognised") for uploads, base64 and own-bucket recordings可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
future-agi/future-agi#3317 ·
维护者通常 1 天内回复
-
Failed agent type collection replaces a complete snapshot with partial data可能已有人在做 @SahilKumar75 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 2 天内回复
-
task
难度 2/5 半天 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 88/100
NousResearch/hermes-agent#133181 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
bmad-code-org/BMAD-METHOD#3041 ·
维护者通常 1 天内回复