Skip to content

Follow symlinks in dotenv set/unset - #702

Open
kavin0x wants to merge 1 commit into
theskumar:mainfrom
kavin0x:fix/cli-follow-symlinks
Open

kavin0x wants to merge 1 commit into
theskumar:mainfrom
kavin0x:fix/cli-follow-symlinks

Conversation

@kavin0x

@kavin0x kavin0x commented Sep 14, 2026

Copy link
Copy Markdown

If .env is a symlink, dotenv set / dotenv unset was rewriting the link itself instead of the target file. Ended up with a regular file where the symlink used to be.

set_key/unset_key already support this via follow_symlinks=True, the CLI just wasn't passing it. Library default is unchanged.

Fixes #541

Test plan

  • CLI tests for set/unset against a symlink (skipped on Windows)
  • sanity check a real linked .env if you have one lying around

rewrite() already knows how to do this, we just were not passing
follow_symlinks through from the CLI so a linked .env would get
replaced by a regular file. Fixes theskumar#541.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dotenv-cli - rewrite() does not resolve symlinks

1 participant