omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

autostarting mise breaks arch (python) packages

Open kromsam opened this issue 1 month ago • 4 comments

System details

Omarchy 3.2.1

What's wrong?

When I install a python package through Arch Repo, I am not able to run it in my terminal because mise 'hijacks' the global python binary, as I have installed python through mise.

For instance, when I run khal, I get the following error:

~ ❯ khal
Traceback (most recent call last):
  File "/usr/bin/khal", line 2, in <module>
    from khal.cli import main_khal
ModuleNotFoundError: No module named 'khal'

For khal to work, I would need to run this command: /usr/bin/python /usr/bin/khal

because:

~ ❯ which python
/home/sam/.local/share/mise/installs/python/3.14.0/bin/python

Another option is to run mise deactivate, which adds bash: command not found: _mise_hook to every command. Oh, and things go south when I try to reactivate mise in the same session again:

~ ❯ mise deactivate
bash: command not found: _mise_hook

~ ❯ mise activate
export MISE_SHELL=bash

# On first activation, save the original PATH
# On re-activation, we keep the saved original
if [ -z "${__MISE_ORIG_PATH:-}" ]; then
  export __MISE_ORIG_PATH="$PATH"
fi

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

  case "$command" in
  deactivate|shell|sh)
    # if argv doesn't contains -h,--help
    if [[ ! " $@ " =~ " --help " ]] && [[ ! " $@ " =~ " -h " ]]; then
      eval "$(command mise "$command" "$@")"
      return $?
    fi
    ;;
  esac
  command 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
# shellcheck shell=bash
export -a chpwd_functions
function __zsh_like_cd()
{
  \typeset __zsh_like_cd_hook
  if
    builtin "$@"
  then
    for __zsh_like_cd_hook in chpwd "${chpwd_functions[@]}"
    do
      if \typeset -f "$__zsh_like_cd_hook" >/dev/null 2>&1
      then "$__zsh_like_cd_hook" || break # finish on first failed hook
      fi
    done
    true
  else
    return $?
  fi
}

# shellcheck shell=bash
[[ -n "${ZSH_VERSION:-}" ]] ||
{
  function cd()    { __zsh_like_cd cd    "$@" ; }
  function popd()  { __zsh_like_cd popd  "$@" ; }
  function pushd() { __zsh_like_cd pushd "$@" ; }
}

chpwd_functions+=(_mise_hook)
_mise_hook
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 [[ "$1" != "mise" && "$1" != "mise-"* ]] && 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
bash: command not found: _mise_hook

Both isn't great. So I wonder. Should we have mise activated all the time? Or would it suffice to only have it running in the ~/Work directory, where it would make more sense?

Here are the two files where mise is activated. https://github.com/basecamp/omarchy/blob/master/config/uwsm/env https://github.com/basecamp/omarchy/blob/master/default/bash/init

kromsam avatar Nov 26 '25 23:11 kromsam

see also: https://github.com/basecamp/omarchy/issues/3528

kromsam avatar Nov 27 '25 15:11 kromsam

See also: #2831 and #2728

Michallote avatar Nov 29 '25 17:11 Michallote

Don't see it noted in the other threads, but an "obvious" workaround is this invocation:

mise use -g python@system

birkirb avatar Nov 29 '25 22:11 birkirb

Both isn't great. So I wonder. Should we have mise activated all the time? Or would it suffice to only have it running in the ~/Work directory, where it would make more sense?

If you are actively developing with python (even if you are not) it is preferable to never modify python installations for the system and use a virtual environment (.venv) for each project instead. The install python command from the menu already install uv which is the preferred python installations and package manager nowadays. I was thinking to simply remove mise python install from the menu altogether as any combination of flags still caused problems. mise is not up to date with package manager practices outlined in

Don't see it noted in the other threads, but an "obvious" workaround is this invocation:

mise use -g python@system

Maybe we should replace line 91 for that one:

https://github.com/basecamp/omarchy/blob/8a37f3dce71b0764e3758cb86478c503a4a8746e/bin/omarchy-install-dev-env#L89-L94

Although I'm not sure what would be the point of having that in the menu (I mean we could remove mise for installing python entirely, python in the system already and it too installs uv after all). It seems to have no effect other than reverting mise if it overwrites the python in PATH. No?

Michallote avatar Dec 01 '25 00:12 Michallote