jdx / mise

dev tools, env vars, task runner
https://mise.jdx.dev
MIT License
8.03k stars 210 forks source link

Activate does not add mise to path #2325

Closed iornstein closed 1 week ago

iornstein commented 1 week ago

Describe the bug In Getting Started, I expected that following the Activate mise steps that it would have added to the path as it indicates. However, running echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc does nothing. In fact, if I try to run ~/.local/bin/mise activate bash directly, I get no change with the following output:

export PATH="/Users/MY_NAME/.local/bin:$PATH"
export MISE_SHELL=bash
export __MISE_ORIG_PATH="$PATH"

mise() {
  local command
  command="${1:-}"
  if [ "$#" = 0 ]; then
    command /Users/MY_NAME/.local/bin/mise
    return
  fi
  shift

  case "$command" in
  deactivate|s|shell)
    # if argv doesn't contains -h,--help
    if [[ ! " $@ " =~ " --help " ]] && [[ ! " $@ " =~ " -h " ]]; then
      eval "$(command /Users/MY_NAME/.local/bin/mise "$command" "$@")"
      return $?
    fi
    ;;
  esac
  command /Users/MY_NAME/.local/bin/mise "$command" "$@"
}

_mise_hook() {
  local previous_exit_status=$?;
  eval "$(mise hook-env -s bash)";
  return $previous_exit_status;
};
if [[ ";${PROMPT_COMMAND:-};" != *";_mise_hook;"* ]]; then
  PROMPT_COMMAND="_mise_hook${PROMPT_COMMAND:+;$PROMPT_COMMAND}"
fi
if [ -z "${_mise_cmd_not_found:-}" ]; then
    _mise_cmd_not_found=1
    if [ -n "$(declare -f command_not_found_handle)" ]; then
        _mise_cmd_not_found_handle=$(declare -f command_not_found_handle)
        eval "${_mise_cmd_not_found_handle/command_not_found_handle/_command_not_found_handle}"
    fi

    command_not_found_handle() {
        if /Users/MY_NAME/.local/bin/mise hook-not-found -s bash -- "$1"; then
          _mise_hook
          "$@"
        elif [ -n "$(declare -f _command_not_found_handle)" ]; then
            _command_not_found_handle "$@"
        else
            echo "bash: command not found: $1" >&2
            return 127
        fi
    }
fi

with MY_NAME being corrected.

Other outputs:

~/.local/bin/mise version
2024.6.6 macos-x64 (409d6e4 2024-06-20)
mise
-bash: mise: command not found

To Reproduce

  1. Install Mise with curl https://mise.run | sh
  2. Attempt to run activate

Expected behavior A clear and concise description of what you expected to happen.

~/.local/bin/mise doctor doctor output

version: 2024.6.6 macos-x64 (409d6e4 2024-06-20)
activated: no
shims_on_path: no

build_info: 
  Target: x86_64-apple-darwin
  Features: DEFAULT, NATIVE_TLS, OPENSSL
  Built: Thu, 20 Jun 2024 16:14:28 +0000
  Rust Version: rustc 1.79.0 (129f3b996 2024-06-10)
  Profile: release

shell: 
  /bin/bash
  GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19)
  Copyright (C) 2007 Free Software Foundation, Inc.

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

config_files: 

backends: 
  cargo
  core
  go
  npm
  pipx
  spm
  ubi

plugins: 
  bun     (core)
  deno    (core)
  erlang  (core)
  go      (core)
  java    (core)
  node    (core)
  python  (core)
  ruby    (core)

toolset: 

env_vars: 
  (none)

settings: 
  activate_aggressive = false
  all_compile = false
  always_keep_download = false
  always_keep_install = false
  asdf_compat = false
  cargo_binstall = true
  color = true
  disable_default_shorthands = false
  disable_tools = []
  experimental = false
  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 = 30
  jobs = 4
  legacy_version_file = true
  legacy_version_file_disable_tools = []
  node_compile = false
  not_found_auto_install = true
  paranoid = false
  plugin_autoupdate_last_check_duration = "7d"
  python_default_packages_file = "/Users/ianornstein/.default-python-packages"
  python_pyenv_repo = "https://github.com/pyenv/pyenv.git"
  raw = false
  trusted_config_paths = []
  quiet = false
  verbose = false
  yes = false
  ci = false
  debug = false
  trace = false
  log_level = "info"
  python_venv_auto_create = false

  [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 If activate is NOT supposed to add mise to path, the instructions could be clearer.

anrub commented 1 week ago

did you try to restart your shell or run source .bashrc as the .bashrc only takes effect on restarts or manual sources. As the docu states:

Make sure you restart your shell session after modifying your rc file in order for it to take effect.

iornstein commented 1 week ago

Thanks!

I restarted my shell a few times and I think there' something unexpected going on, as that should have worked. It turns out sourceing directly did it. I have to look into my terminal settings further, but that's some misconfiguration on my part and not on mise. Thanks for the help.

I did expect ~/.local/bin/mise doctor to work regardless of sourcing that though.