Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a strict_env compatible version of source_up #913

Closed
jfly opened this issue Mar 27, 2022 · 4 comments · Fixed by #921
Closed

Provide a strict_env compatible version of source_up #913

jfly opened this issue Mar 27, 2022 · 4 comments · Fixed by #921
Labels

Comments

@jfly
Copy link
Contributor

jfly commented Mar 27, 2022

(This request is very similar to #728, but with source_up)

Right now, source_up searches upwards (using find_up) until it finds a file. If it doesn't, it exits 1, and if you've got strict_env turned on, loading the .envrc file immediately stops.

Is this intentional? The docstring on source_up sort of makes it sound like maybe it was intended to happily ignore missing files?

Loads another ".envrc" if found with the find_up command.

If it is intentional that source_up exits nonzero when there's no ancestor file, how would you feel about a PR adding a new source_up_if_exists method?

@jfly jfly added the Feature label Mar 27, 2022
@zimbatm
Copy link
Member

zimbatm commented Mar 27, 2022

The exit status is intentional to be able to distinguish if a file was loaded or not.

I don't mind having source_up_if_exists being added. A simple workaround is to use source_up || true.

jfly added a commit to jfly/direnv that referenced this issue Apr 8, 2022
This fixes direnv#913

While I was in here, I opted to make the existing `source_up` script log
explicitly when it can't find a file. I think that's useful both with
strict_env enabled and disabled.
@Zebradil
Copy link

Zebradil commented Apr 9, 2022

I spend some time trying to figure out why my .envrc doesn't export variables. For me it could've been helpful to see an error message about failed source_up.

@jfly
Copy link
Contributor Author

jfly commented Apr 9, 2022

@Zebradil check out #921, I think it'll make that situation a little better.

@Zebradil
Copy link

Zebradil commented Apr 9, 2022

@jfly yes, that looks great, thank you!

zimbatm added a commit that referenced this issue Apr 14, 2022
This fixes #913

While I was in here, I opted to make the existing `source_up` script log
explicitly when it can't find a file. I think that's useful both with
strict_env enabled and disabled.

Co-authored-by: zimbatm <zimbatm@zimbatm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

3 participants