twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
13.41k stars 493 forks source link

`chezmoi cd` breaks `asdf` #2928

Closed yozachar closed 1 year ago

yozachar commented 1 year ago

Describe the bug

chezmoi cd breaks asdf installed using zsh-snap.

To reproduce

Here's my

~/.zshrc

# If not running interactively, do nothing
[[ $- != *i* ]] && return

# Zsh
HISTFILE=~/.zsh_history
HISTSIZE=100000
SAVEHIST=$HISTSIZE
setopt append_history # append rather then overwrite
setopt inc_append_history # add history immediately after typing a command
export EDITOR=micro

# aliases
alias ls='LC_ALL=C ls -h --group-directories-first --color=auto'
alias which='whence -p'

# keybindings
source ~/.zsh_keybindings

# Download Znap, if it's not there yet.
[[ -f ~/.znap/src/znap.zsh ]] ||
    git clone --depth 1 -- https://github.com/marlonrichert/zsh-snap.git ~/.znap/src
# Set znap repo directory
zstyle ':znap:*' repos-dir ~/.znap/repos

# source znap
source ~/.znap/src/znap.zsh

# tools
znap install asdf-vm/asdf
znap install andreafrancia/trash-cli
znap install refi64/stylepak

# zsh-snap plugins
znap source asdf-vm/asdf
znap source zsh-users/zsh-autosuggestions
znap source zsh-users/zsh-syntax-highlighting

# asdf
asdf reshim

# zsh-snap prompt
echo -e "\n$(neofetch)"
znap eval starship 'starship init zsh --print-full-init'
znap prompt

  1. In a VM / container you can install zsh and use this configurations.
  2. Install chezmoi, and do chezmoi add ~/.zshrc
  3. When I do chezmoi cd, I see this sort of:
warning ```console /home/user-name/.local/bin/asdf: line 4: /home/user-name/.local/lib/utils.bash: No such file or directory /home/user-name/.local/bin/asdf: line 72: asdf_default_tool_versions_filename: command not found /home/user-name/.local/bin/asdf: line 75: asdf_config_file: command not found /home/user-name/.local/bin/asdf: line 78: asdf_data_dir: command not found /home/user-name/.local/bin/asdf: line 81: asdf_dir: command not found /home/user-name/.local/bin/asdf: line 27: asdf_dir: command not found /home/user-name/.local/bin/asdf: line 101: asdf_dir: command not found Unknown command: `asdf reshim` /home/user-name/.local/bin/asdf: line 103: /lib/commands/command-help.bash: No such file or directory ```

Expected behavior

It simply changes directory to /home/user-name/.local/share/chezmoi, without any such 'warning'.

Output of command with the --verbose flag

Output ```console $ chezmoi --verbose cd /home/user-name/.local/bin/asdf: line 4: /home/user-name/.local/lib/utils.bash: No such file or directory /home/user-name/.local/bin/asdf: line 72: asdf_default_tool_versions_filename: command not found /home/user-name/.local/bin/asdf: line 75: asdf_config_file: command not found /home/user-name/.local/bin/asdf: line 78: asdf_data_dir: command not found /home/user-name/.local/bin/asdf: line 81: asdf_dir: command not found /home/user-name/.local/bin/asdf: line 27: asdf_dir: command not found /home/user-name/.local/bin/asdf: line 101: asdf_dir: command not found Unknown command: `asdf reshim` /home/user-name/.local/bin/asdf: line 103: /lib/commands/command-help.bash: No such file or directory ```

Output of chezmoi doctor

```console $ chezmoi doctor RESULT CHECK MESSAGE warning version v2.33.1, built at 2023-04-08T07:27:16Z ok latest-version v2.33.1 ok os-arch linux/amd64 (Arch Linux) ok uname Linux tesseract 6.2.11-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 13 Apr 2023 16:59:24 +0000 x86_64 GNU/Linux ok go-version go1.20.3 (gc) ok executable /usr/bin/chezmoi ok config-file no config file found warning source-dir ~/.local/share/chezmoi is a git working tree (dirty) ok suspicious-entries no suspicious entries warning working-tree ~/.local/share/chezmoi is a git working tree (dirty) ok dest-dir ~ is a directory ok umask 022 ok cd-command found /usr/bin/zsh ok cd-args /usr/bin/zsh info diff-command not set ok edit-command found /usr/bin/micro ok edit-args /usr/bin/micro ok git-command found /usr/bin/git, version 2.40.0 ok merge-command found /usr/bin/vimdiff ok shell-command found /usr/bin/zsh ok shell-args /usr/bin/zsh info age-command age not found in $PATH ok gpg-command found /usr/bin/gpg, version 2.2.41 info pinentry-command not set info 1password-command op not found in $PATH info bitwarden-command bw not found in $PATH info dashlane-command dcli not found in $PATH info gopass-command gopass not found in $PATH info keepassxc-command keepassxc-cli not found in $PATH info keepassxc-db not set info keeper-command keeper not found in $PATH info lastpass-command lpass not found in $PATH info pass-command pass not found in $PATH info passhole-command ph not found in $PATH info rbw-command rbw not found in $PATH info vault-command vault not found in $PATH info secret-command not set ```

Additional context

Behavior of asdf changes:

$ which asdf
/home/user-name/.znap/repos/asdf/bin/asdf
$ asdf --version
v0.11.3-2dd65e0
$ chezmoi cd
/home/user-name/.local/bin/asdf: line 4: /home/user-name/.local/lib/utils.bash: No such file or directory
/home/user-name/.local/bin/asdf: line 72: asdf_default_tool_versions_filename: command not found
/home/user-name/.local/bin/asdf: line 75: asdf_config_file: command not found
/home/user-name/.local/bin/asdf: line 78: asdf_data_dir: command not found
/home/user-name/.local/bin/asdf: line 81: asdf_dir: command not found
/home/user-name/.local/bin/asdf: line 27: asdf_dir: command not found
/home/user-name/.local/bin/asdf: line 101: asdf_dir: command not found
Unknown command: `asdf reshim`
/home/user-name/.local/bin/asdf: line 103: /lib/commands/command-help.bash: No such file or directory
$ whcch asdf
/home/user-name/.local/bin/asdf
$ asdf --version
/home/user-name/.local/bin/asdf: line 4: /home/user-name/.local/lib/utils.bash: No such file or directory
/home/user-name/.local/bin/asdf: line 72: asdf_default_tool_versions_filename: command not found
/home/user-name/.local/bin/asdf: line 75: asdf_config_file: command not found
/home/user-name/.local/bin/asdf: line 78: asdf_data_dir: command not found
/home/user-name/.local/bin/asdf: line 81: asdf_dir: command not found
/home/user-name/.local/bin/asdf: line 27: asdf_dir: command not found
/home/user-name/.local/bin/asdf: line 101: asdf_dir: command not found
Unknown command: `asdf --version`
/home/user-name/.local/bin/asdf: line 103: /lib/commands/command-help.bash: No such file or directory

I suspect, this is a zsh-snap issue, and chezmoi is exposing it?

yozachar commented 1 year ago

This is zsh-snap issue.