-
Notifications
You must be signed in to change notification settings - Fork 263
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
mise exec --cd
option doesn't activate tools or env
#1843
Comments
My current work-around is to use the GNU $ env -C /tmp/foo/bar mise exec -- printenv FOO
123 note: the built-in macOS $ cat ~/.local/bin/mise_
#! /bin/sh
# work around broken cd functionality in mise
set -eu
MISE_BIN="/opt/homebrew/bin/mise" # or wherever it's installed
N=$#
I=0
DONE=0
NAME=""
while [ ${I} -lt ${N} ]; do
I=$((I + 1))
ARG=$1
shift
if [ ${DONE} = 0 ]; then
if [ "${ARG}" = "--" ]; then
DONE=1
elif [ "${NAME}" = "cd" ]; then
NAME=""
cd -- "${ARG}" || exit 1
continue
elif [ "${ARG}" = "--cd" ] || [ "${ARG}" = "-C" ]; then
NAME="cd"
continue
fi
fi
set -- "$@" "${ARG}"
done
exec "${MISE_BIN}" "$@" |
Additionally, if I create a virtual-environment, it will "activate" as expected when I'm in the target directory, but it will not be picked up from outside the directory with the
note: the
A similar result is obtained from the
|
I'm still learning Rust, but this seems to address the problem by having diff --git a/src/config/settings.rs b/src/config/settings.rs
index e5cd4630..ef8b2903 100644
--- a/src/config/settings.rs
+++ b/src/config/settings.rs
@@ -197,13 +197,11 @@ impl Settings {
if let Some(settings) = SETTINGS.read().unwrap().as_ref() {
return Ok(settings.clone());
}
+
let mut sb = Self::builder()
.preloaded(CLI_SETTINGS.lock().unwrap().clone().unwrap_or_default())
.env();
- for file in Self::all_settings_files() {
- sb = sb.preloaded(file);
- }
- let mut settings = sb.preloaded(DEFAULT_SETTINGS.clone()).load()?;
+ let mut settings = sb.load()?;
if let Some(cd) = &settings.cd {
static ORIG_PATH: Lazy<std::io::Result<PathBuf>> = Lazy::new(env::current_dir);
let mut cd = PathBuf::from(cd);
@@ -212,6 +210,14 @@ impl Settings {
}
env::set_current_dir(cd)?;
}
+
+ sb = Self::builder()
+ .preloaded(CLI_SETTINGS.lock().unwrap().clone().unwrap_or_default())
+ .env();
+ for file in Self::all_settings_files() {
+ sb = sb.preloaded(file);
+ }
+ settings = sb.preloaded(DEFAULT_SETTINGS.clone()).load()?;
if settings.raw {
settings.jobs = 1;
} |
Description
The
-C/--cd
option doesn't appear to resolvetools
orenv
directives.To Reproduce
Create a directory with a
.mise.toml
with the following contents:When inside the target directory, the environment variable activates as expected (I'm using the shell hooks and shims):
However, when using the option to change directory, the environment variable isn't resolved, even though it definitely appears that the directory is being changed when testing with
pwd
:Expected behavior
I expect that
tools
andenv
are resolved when using the-C/--cd
option.mise doctor
outputAdditional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: