Closed tomtseng closed 4 months ago
Thanks for the PR! Although this is a clean fix, I worry that addressing this issue will cause breakage. The readme states:
When executing, autoenv, will walk up the directories until the mount point and execute all .env files beginning at the top.
I don't want to make any changes that run contrary to that, since it's the intended behavior, even if it's possibly counter-intuitive.
I thought of one tangible case that could break downstream consumers:
.env
file at /home/user/.env
with contents export GITHUB_TOKEN=...
(assume token has "general permissions").env
file at /home/user/Projects/project1/.env
with contents export GITHUB_TOKEN=...
(assume token has "specific permissions")cd
ing from /home/user/Projects/project1
from /home/user/Projects/project2
, these new changes will no longer source /home/user/.env
, meaning the token with the "general permissions" will not be used.
Fixes #228.
Issue
Suppose we
cd
from/a/b/c
to/a/y/z
.Expected behavior: Presumably we've already invoked
/.env
,/a/.env
, and/a/b/.env
when wecd
ed into/a/b/c
, so I expect nowcd
ing intoa/y/z/
to only invoke/a/y/.env
and/a/y/z/.env
.Actual behavior: Invokes envs in all ancestors of
/a/y/z
:/.env
,/a/.env
,/a/y/.env
, and/a/y/z/.env
.Changes
autoenv_init()
, when traversing up from/a/y/z
, stop traversing once the previous directory/a/b/c
is a child of the currently travsed directory.