-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
Environment scripts are sourced in the context of the current working directory #2335
Labels
Comments
jdx
added a commit
that referenced
this issue
Dec 11, 2024
jdx
added a commit
that referenced
this issue
Dec 11, 2024
jdx
added a commit
that referenced
this issue
Dec 11, 2024
jdx
added a commit
that referenced
this issue
Dec 11, 2024
jdx
added a commit
that referenced
this issue
Dec 11, 2024
jdx
added a commit
that referenced
this issue
Dec 11, 2024
jdx
added a commit
that referenced
this issue
Dec 11, 2024
jdx
added a commit
that referenced
this issue
Dec 11, 2024
jdx
added a commit
that referenced
this issue
Dec 11, 2024
jdx
added a commit
that referenced
this issue
Dec 11, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When I use
_.source =
to export environment variables, the script seems o be evaluated in the context of the current working directory rather than relative to the config file which sourced the script. This makes it very awkward to refer to paths relative to the script/config, as you can't use${dirname "$0"}
in a sourced script. You can work around it with${BASH_SOURCE[0]}
but that isn't portable.I often want to refer to paths in context of each Mise config, so currently I'm using this, although it's not ideal:
It seems like the sourced script gets evaluated whenever you enter a directory managed by Mise, or evaluated again if you enter a further nested directory with its own Mise config (which is where you're most likely to run into it). If you just enter the project directory, it will be evaluated at the project root, but if you skip that and enter the directory tree at some nested directory first, then the script will be evaluated from there.
To Reproduce
And if you have a nested Mise config, it will also be evaluated when you enter that context:
Expected behavior
The script should be sourced relative to the config file (perhaps this means temporarily changing the working directory while the script is sourced, then back). This allows scripts to reliably refer to paths relative to the Mise configuration context that they're defined in.
mise doctor
outputThe text was updated successfully, but these errors were encountered: