mise activate nu emits invalid code
#6876
-
|
As you can see, lines 1-4 of the output from set,PATH,# REDACTED, but this isn't the problematic part
hide,MISE_SHELL,
hide,__MISE_DIFF,
hide,__MISE_DIFF,
export-env {
$env.MISE_SHELL = "nu"
let mise_hook = {
condition: { "MISE_SHELL" in $env }
code: { mise_hook }
}
add-hook hooks.pre_prompt $mise_hook
add-hook hooks.env_change.PWD $mise_hook
}
def --env add-hook [field: cell-path new_hook: any] {
let field = $field | split cell-path | update optional true | into cell-path
let old_config = $env.config? | default {}
let old_hooks = $old_config | get $field | default []
$env.config = ($old_config | upsert $field ($old_hooks ++ [$new_hook]))
}
def "parse vars" [] {
$in | from csv --noheaders --no-infer | rename 'op' 'name' 'value'
}
export def --env --wrapped main [command?: string, --help, ...rest: string] {
let commands = ["deactivate", "shell", "sh"]
if ($command == null) {
^"/Users/michael/.local/bin/mise"
} else if ($command == "activate") {
$env.MISE_SHELL = "nu"
} else if ($command in $commands) {
^"/Users/michael/.local/bin/mise" $command ...$rest
| parse vars
| update-env
} else {
^"/Users/michael/.local/bin/mise" $command ...$rest
}
}
def --env "update-env" [] {
for $var in $in {
if $var.op == "set" {
if ($var.name | str upcase) == 'PATH' {
$env.PATH = ($var.value | split row (char esep))
} else {
load-env {($var.name): $var.value}
}
} else if $var.op == "hide" {
hide-env $var.name
}
}
}
def --env mise_hook [] {
^"/Users/michael/.local/bin/mise" hook-env -s nu
| parse vars
| update-env
}
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 11 replies
-
|
Broken in |
Beta Was this translation helpful? Give feedback.
-
|
I am also experiencing the same issue, but it only happens occasionally when open up a new session. error message
|
Beta Was this translation helpful? Give feedback.
-
|
After doing some let mut out = String::new();
out.push_str(&shell::build_deactivation_script(self)); // <- this one
let inline_prelude = self.format_activate_prelude_inline(&opts.prelude);
out.push_str(&formatdoc! {r#"I'm not sure it actually needs to be there, as every test continues to pass without it. But I also never deactivate my mise, so I have no idea if this would remove functionality 🤷 |
Beta Was this translation helpful? Give feedback.
-
|
The newest fix seems to be breaking my nushell config. I'm running 0.108.0, if that's relevant. |
Beta Was this translation helpful? Give feedback.
if i create ~/.cache/mise/init.nu with
then it works every time, even from an activated session (because
env -idoes not pass environment variables through to themiseprocess)