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

chezmoi cd errors with chezmoi: already in a chezmoi subshell when in a different subshell #3410

Closed
willdhorn opened this issue Dec 16, 2023 · 5 comments
Labels
support Support request

Comments

@willdhorn
Copy link

Describe the bug

When I try to run chezmoi cd from the vscode integrated terminal, it fails with the message chezmoi: already in a chezmoi subshell. I know that a brand new terminal in vscode (running zsh on macos) has a $SHLVL of 4, so if chezmoi uses that to detect if it's in a subshell then I could see how that would cause a problem.

If that is why it's failing, would it be possible to set an environment variable as a flag for whether a chezmoi cd subshell is active so that it's still possible to run it inside other, unrelated, subshells?

@twpayne twpayne added the support Support request label Dec 16, 2023
@twpayne
Copy link
Owner

twpayne commented Dec 16, 2023

What is the output of chezmoi doctor?

@willdhorn
Copy link
Author

willdhorn commented Dec 16, 2023

So it works when run unset CHEZMOI_SUBSHELL, and it works normally again for that session, but when I open up a brand new terminal in vscode echo $CHEZMOI_SUBSHELL is 1.

edit: it is not set when open a new terminal in iTerm

Output of chezmoi doctor:

Does not change when CHEZMOI_SUBSHELL is set or not

$ chezmoi doctor
RESULT    CHECK                       MESSAGE
ok        version                     v2.42.2, commit ea1e143fe416097792706a708144ffda0d85b268, built at 2023-12-02T01:29:57Z, built by Homebrew
ok        latest-version              v2.42.2
ok        os-arch                     darwin/arm64
ok        uname                       Darwin My-MacBook-Pro.local 22.6.0 Darwin Kernel Version 22.6.0: Wed Oct  4 21:26:55 PDT 2023; root:xnu-8796.141.3.701.17~4/RELEASE_ARM64_T6020 arm64
ok        go-version                  go1.21.4 (gc)
ok        executable                  /opt/homebrew/bin/chezmoi
ok        upgrade-method              brew-upgrade
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 /bin/zsh
ok        cd-args                     /bin/zsh
info      diff-command                not set
ok        edit-command                found /usr/bin/vi
ok        edit-args                   /usr/bin/vi
ok        git-command                 found /opt/homebrew/bin/git, version 2.43.0
ok        merge-command               found /usr/bin/vimdiff
ok        shell-command               found /bin/zsh
ok        shell-args                  /bin/zsh
info      age-command                 age not found in $PATH
info      gpg-command                 gpg not found in $PATH
info      pinentry-command            not set
info      1password-command           op not found in $PATH
ok        bitwarden-command           found /opt/homebrew/bin/bw, version 2023.10.0
info      bitwarden-secrets-command   bws not found in $PATH
info      dashlane-command            dcli not found in $PATH
info      doppler-command             doppler 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      vlt-command                 vlt not found in $PATH
info      secret-command              not set

@twpayne
Copy link
Owner

twpayne commented Dec 16, 2023

This means that $CHEZMOI_SUBSHELL is already set. Did you launch VSCode from inside a chezmoi subshell?

@willdhorn
Copy link
Author

Yep that must've been it. I haven't edited my dotfiles in a couple week, but I guess I haven't quit vscode since then. Thanks! (I'll go set my chezmoi editor to vscode now lol)

@twpayne
Copy link
Owner

twpayne commented Dec 16, 2023

Thanks for the investigation. On reflection, I don't think the "already in a chezmoi subshell" error is needed. I'll remove it.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
support Support request
Projects
None yet
Development

No branches or pull requests

2 participants