Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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 failed to activate in nushell 0.99.0 #2768

Closed
tifandotme opened this issue Oct 16, 2024 · 4 comments
Closed

mise failed to activate in nushell 0.99.0 #2768

tifandotme opened this issue Oct 16, 2024 · 4 comments
Labels

Comments

@tifandotme
Copy link

tifandotme commented Oct 16, 2024

Describe the bug
mise failed to activate in Nushell 0.99.0:

Screenshot 2024-10-16 at 22 51 21

To Reproduce

  1. Install nushell 0.99.0
  2. Add to ~/.config/nushell/env.nu
let mise_path = $nu.default-config-dir | path join scripts mise.gen.nu
^mise activate nu | save --force $mise_path
  1. Add to ~/.config/nushell/config.nu
use mise.gen.nu

Expected behavior
Should not have any error when nu starts.
node -v should also work

mise doctor output

version: 2024.10.7 macos-arm64 (2024-10-14)
activated: no
shims_on_path: no

build_info:
  Target: aarch64-apple-darwin
  Features: DEFAULT, NATIVE_TLS
  Built: Mon, 14 Oct 2024 22:13:17 +0000
  Rust Version: rustc 1.81.0 (eeb90cda1 2024-09-04) (Homebrew)
  Profile: release

shell:
  /opt/homebrew/bin/nu
  0.99.0

dirs:
  data: ~/.local/share/mise
  config: ~/.config/mise
  cache: ~/.cache/mise
  state: ~/.local/state/mise
  shims: ~/.local/share/mise/shims

config_files:
  ~/.config/mise/config.toml

backends:
  cargo
  core
  go
  npm
  pipx
  spm
  ubi
  vfox

plugins:

toolset:
  [email protected]
  [email protected]
  [email protected]

env_vars:
  (none)

settings:
  activate_aggressive = false
  all_compile = false
  always_keep_download = false
  always_keep_install = false
  asdf_compat = false
  cache_prune_age = "30d"
  ci = false
  color = true
  debug = false
  disable_backends = []
  disable_default_registry = false
  disable_hints = []
  disable_tools = []
  experimental = false
  fetch_remote_versions_cache = "1h"
  fetch_remote_versions_timeout = "10s"
  go_default_packages_file = "~/.default-go-packages"
  go_download_mirror = "https://dl.google.com/go"
  go_repo = "https://github.com/golang/go"
  go_set_gopath = false
  go_set_goroot = true
  go_skip_checksum = false
  http_timeout = "30s"
  jobs = 4
  legacy_version_file = true
  legacy_version_file_disable_tools = []
  libgit2 = true
  log_level = "info"
  not_found_auto_install = true
  paranoid = false
  pin = false
  plugin_autoupdate_last_check_duration = "7d"
  python_default_packages_file = "~/.default-python-packages"
  quiet = false
  raw = false
  trace = false
  trusted_config_paths = []
  use_versions_host = true
  verbose = false
  yes = false

  [cargo]
  binstall = true

  [node]

  [pipx]
  uvx = false

  [python]
  default_packages_file = "~/.default-python-packages"
  pyenv_repo = "https://github.com/pyenv/pyenv.git"
  venv_auto_create = false
  venv_stdlib = false

  [ruby]
  default_packages_file = "~/.default-gems"
  ruby_build_repo = "https://github.com/rbenv/ruby-build.git"
  ruby_install = false
  ruby_install_repo = "https://github.com/postmodern/ruby-install.git"

  [status]
  missing_tools = "if_other_versions_installed"
  show_env = false
  show_tools = false
No warnings found
1 problem found:

1. mise is not activated, run mise help activate or
   read documentation at https://mise.jdx.dev for activation instructions.
   Alternatively, add the shims directory ~/.local/share/mise/shims to PATH.
   Using the shims directory is preferred for non-interactive setups.

Additional context
Add any other context about the problem here. Consider running mise with --debug or --trace for extra debug info.

@tifandotme tifandotme added the bug label Oct 16, 2024
@robrecord
Copy link

robrecord commented Nov 11, 2024

Looks like it could possibly be due to this change:
nushell/nushell@fce6146
...which (rightly or wrongly) causes $env.config.hooks.env_change to be empty.

I am assuming this is a bug in nushell 0.99, as the change hasn't been documented in their changelog.

I have rolled back to nushell v.0.98.0 for now

@xd003
Copy link

xd003 commented Nov 16, 2024

Facing the very same issue, closing the one i had opened here as i didn't realized this is an ongoing issue since over a month

@WolfDan
Copy link

WolfDan commented Nov 20, 2024

I ran into the same issue, I managed to solve it by appending the following at top of the generated file

$env.config = ($env | default {} config).config
$env.config = ($env.config | default {} hooks)
$env.config = ($env.config | update hooks ($env.config.hooks | default {} env_change))
$env.config = ($env.config | update hooks.env_change ($env.config.hooks.env_change | default [] PWD))

This will add the default PWD if it does not exist in env_change, I think adding this to https://github.com/jdx/mise/blob/main/src/shell/nushell.rs should solve the issue but I'm not sure since I'm using nixos to setup mise and nushell

I'm using nixos with home-manager for this, so I'm using the following code

{ config, pkgs, ... }:

let
  miseCmd = "${config.home.profileDirectory}/bin/mise";
in
{
  # mise
  programs.mise.enable = true;
  programs.nushell = {
      extraEnv = ''
        let mise_cache = "${config.xdg.cacheHome}/mise"
        if not ($mise_cache | path exists) {
          mkdir $mise_cache
        }

        $env.config = ($env | default {} config).config
        $env.config = ($env.config | default {} hooks)
        $env.config = ($env.config | update hooks ($env.config.hooks | default {} env_change))
        $env.config = ($env.config | update hooks.env_change ($env.config.hooks.env_change | default [] PWD))

        ${miseCmd} activate nu | save --force ${config.xdg.cacheHome}/mise/mise.nu
      ''; 
      extraConfig = ''
        use ${config.xdg.cacheHome}/mise/mise.nu
      '';
    };
}

@xd003
Copy link

xd003 commented Nov 20, 2024

Oh i forgot to update here that the fix for this issue has already been merged in nushell. It will be available in the next release nushell/nushell#14341.
In the mean time, before setting any env_change hooks, simply add $env.config.hooks.env_change = {} to your config.

PS / Info given by nushell dev on discord

Repository owner locked and limited conversation to collaborators Dec 14, 2024
@jdx jdx converted this issue into discussion #3552 Dec 14, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

4 participants