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

source_env: show full path #870

Merged
merged 1 commit into from Apr 11, 2022
Merged

source_env: show full path #870

merged 1 commit into from Apr 11, 2022

Conversation

eval
Copy link
Contributor

@eval eval commented Dec 28, 2021

Paths passed to source_env(_if_exists) are logged as-is, e.g. .envrc.local.
This PR ensures the full path is logged, like with source_up.

$ cat foo/.envrc
source_up
source_env .envrc.local

# CURRENT
$ direnv exec foo true
direnv: loading ~/src/direnv/foo/.envrc
direnv: loading ~/src/direnv/.envrc
direnv: loading .envrc.local

# PR
$ direnv exec foo true
direnv: loading ~/src/direnv/foo/.envrc
direnv: loading ~/src/direnv/.envrc
direnv: loading ~/src/direnv/foo/.envrc.local

@CrystalMethod
Copy link

We have already stumbled across this several times. If you have an ".envrc.local" in both directories, you get the same logging twice, which often leads to the assumption that the same file is sourced twice.

direnv: loading ~/src/direnv/foo/.envrc
direnv: loading ~/src/direnv/.envrc
direnv: loading .envrc.local
direnv: loading .envrc.local

stdlib.sh Outdated
@@ -346,7 +346,7 @@ source_env() {
pushd "$(pwd 2>/dev/null)" >/dev/null || return 1
pushd "$rcpath_dir" >/dev/null || return 1
if [[ -f ./$rcpath_base ]]; then
log_status "loading $rcfile"
log_status "loading $(expand_path "$rcpath")"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the expand_path be amended to show ~ instead of user home path?
Kind of:

Suggested change
log_status "loading $(expand_path "$rcpath")"
log_status "loading $(expand_path "$rcpath" | sed 's|^'${HOME:=none}'|~|')"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yermulnik thanks for catching the regression! user_rel_path did it eventually.

@eval eval changed the title Show full path source_env: show full path Apr 6, 2022
Before:
Given ~/path/to/.envrc containing:
source_env .envrc.local

When doing `direnv exec ~/path/to true` it shows:
direnv: loading .envrc.local

After:
It shows:
direnv: loading ~/path/to/.envrc.local
@eval
Copy link
Contributor Author

eval commented Apr 6, 2022

@zimbatm thoughts on this one? 🙏🏻

@zimbatm zimbatm merged commit d08393b into direnv:master Apr 11, 2022
@zimbatm
Copy link
Member

zimbatm commented Apr 11, 2022

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants