Skip to content
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

Warning on startup zsh #23

Closed
3 tasks done
huyhandes opened this issue Nov 7, 2024 · 2 comments
Closed
3 tasks done

Warning on startup zsh #23

huyhandes opened this issue Nov 7, 2024 · 2 comments
Labels

Comments

@huyhandes
Copy link

Prerequisites

  • I've checked the existing issues and I'm not duplicating a report.
  • I've checked the zimfw Changelog and I'm not being affected by documented changes.
  • I've checked the zimfw 📢 Announcements and I'm not being affected by announced changes.

Bug description

warning: completion was already initialized before completion module. Will call compinit again. See https://github.com/zimfw/zimfw/wiki/Troubleshooting#completion-is-not-working

I'm sure that there no compinit in dotfiles

Steps to reproduce

  1. Open new terminal tab

Current behavior

Show warning when open new zsh terminal tab

Expected behavior

No warning show

zimfw info

zimfw version:        1.15.1 (built at 2024-10-10 00:28:19 UTC, previous commit is 331f1c5)
LANG:                 en_US.UTF-8
LC_ALL:               en_US.UTF-8
OSTYPE:               darwin24.0
TERM:                 xterm-256color
TERM_PROGRAM:         tmux
TERM_PROGRAM_VERSION: 3.5a
ZIM_HOME:             /Users/huybui/.zim
ZSH_VERSION:          5.9

Additional context

export DOTFILES="$HOME/dotfiles"
export ZIM_HOME=$HOME/.zim

source $HOME/.aliases
source $HOME/.exports
source $HOME/.functions

if [[ "$OSTYPE" =~ ^linux ]]; then
  source "$DOTFILES/linux/.ext_exports"
  source "$DOTFILES/linux/.micromamba"
elif [[ "$OSTYPE" == "darwin"* ]]; then
  source "$DOTFILES/macos/.ext_exports"
  source "$DOTFILES/macos/.micromamba"
  source "$HOME/.kube/load-k8s-config.sh"
else
  echo "No ext exports for this platform"
fi
if test -d "$HOME/opt/rye"; then
  source "$HOME/opt/rye/env"
fi
typeset -U path
typeset -U fpath

source ${ZIM_HOME}/init.zsh
fsh-alias XDG:catppuccin-macchiato -q

eval "$(starship init zsh)"

zimrc:

zmodule completion
zmodule exa
zmodule input
zmodule environment
zmodule fzf

zmodule ohmyzsh/ohmyzsh --root plugins/git
zmodule ohmyzsh/ohmyzsh --root plugins/colored-man-pages
zmodule ohmyzsh/ohmyzsh --root plugins/command-not-found
zmodule ohmyzsh/ohmyzsh --root plugins/fzf
zmodule Aloxaf/fzf-tab --source fzf-tab.plugin.zsh
zmodule ohmyzsh/ohmyzsh --root plugins/zoxide
zmodule MichaelAquilina/zsh-you-should-use
zmodule zdharma-continuum/fast-syntax-highlighting
@huyhandes huyhandes added the bug label Nov 7, 2024
@huyhandes
Copy link
Author

I found out that the micromamba binary have the compinit in it.

This is the output of mamba shell hook

# Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause

__mamba_exe() (
    "/shared/huybq/bin/micromamba" "${@}"
)

__mamba_hashr() {
    if [ -n "${ZSH_VERSION:+x}" ]; then
        \rehash
    elif [ -n "${POSH_VERSION:+x}" ]; then
        :  # pass
    else
        \hash -r
    fi
}

__mamba_xctivate() {
    \local ask_conda
    ask_conda="$(PS1="${PS1:-}" __mamba_exe shell "${@}" --shell bash)" || \return
    \eval "${ask_conda}"
    __mamba_hashr
}

micromamba() {
    \local cmd="${1-__missing__}"
    case "${cmd}" in
        activate|reactivate|deactivate)
            __mamba_xctivate "${@}"
            ;;
        install|update|upgrade|remove|uninstall)
            __mamba_exe "${@}" || \return
            __mamba_xctivate reactivate
            ;;
        self-update)
            __mamba_exe "${@}" || \return

            # remove leftover backup file on Windows
            if [ -f "/shared/huybq/bin/micromamba.bkup" ]; then
                rm -f "/shared/huybq/bin/micromamba.bkup"
            fi
            ;;
        *)
            __mamba_exe "${@}"
            ;;
    esac
}

if [ -z "${CONDA_SHLVL+x}" ]; then
    \export CONDA_SHLVL=0
    # In dev-mode MAMBA_EXE is python.exe and on Windows
    # it is in a different relative location to condabin.
    if [ -n "${_CE_CONDA+x}" ] && [ -n "${WINDIR+x}" ]; then
        PATH="${MAMBA_ROOT_PREFIX}/condabin:${PATH}"
    else
        PATH="${MAMBA_ROOT_PREFIX}/condabin:${PATH}"
    fi
    \export PATH

    # We're not allowing PS1 to be unbound. It must at least be set.
    # However, we're not exporting it, which can cause problems when starting a second shell
    # via a first shell (i.e. starting zsh from bash).
    if [ -z "${PS1+x}" ]; then
        PS1=
    fi
fi

if [ -n "${ZSH_VERSION:+x}" ]; then
  if ! command -v compinit > /dev/null; then
    autoload -U +X compinit && if [[ "${ZSH_DISABLE_COMPFIX-}" = true ]]; then
      compinit -u
    else
      compinit
    fi
  fi
  autoload -U +X bashcompinit && bashcompinit

  _umamba_zsh_completions()
  {
    COMPREPLY=($(__mamba_exe completer "${(@s: :)${(@s: :)COMP_LINE}:1}"))
  }

  complete -o default -F _umamba_zsh_completions micromamba
fi
if [ -n "${BASH_VERSION:+x}" ]; then
  _umamba_bash_completions()
  {
    COMPREPLY=($(__mamba_exe completer "${COMP_WORDS[@]:1}"))
  }
  complete -o default -F _umamba_bash_completions micromamba
fi


@ericbn
Copy link
Member

ericbn commented Nov 7, 2024

Yes, I've found that some CLI tools call compinit themselves instead of just providing a _tool file in the fpath. I've seen this with Twilio CLI too for example. It's bad and can break the completion system. I hope our completion module is helping users spot these bad behaviors in third party tools and work around them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants