Skip to content

chezmoi edit does not favor $EDITOR evn variable in zsh, $env.EDITOR in nushell, but favors in bash #4996

@pddshk

Description

@pddshk

Description

Even when env variable $EDITOR is set, chezmoi still tried to launch nano as editor

To reproduce

  1. set env var $EDITOR to smth except nano
  2. run chezmoi edit ~/.config/some_file

Expected behavior

chezmoi opens whichever editor is configured in $EDITOR. It is arguable that it should fallback to anything

Output of command with the --verbose flag

with zsh:

pddshk@solus in chezmoi on  HEAD (6624b49)git status
HEAD detached at v2.70.0
nothing to commit, working tree cleanmake
go build . || ( rm -f chezmoi ; false )./chezmoi --version
chezmoi version dev, commit 6624b49786a9f039f05b4d929c35fd4f4bf17337, built at 2026-03-09T22:45:19Zecho $EDITOR
/usr/bin/nvimwhich nvim
/usr/bin/nvimchezmoi --verbose edit ~/.config/starship.toml
chezmoi: warning: /usr/bin/nano /home/pddshk/.local/share/chezmoi/private_dot_config/starship.toml: returned in less than 1s
chezmoi: /usr/bin/nano: fork/exec /usr/bin/nano: no such file or directory

with nushell

$env.EDITOR
/usr/bin/nvimwhich nvim
╭───┬─────────┬───────────────┬──────────╮
│ # │ command │     path      │   type   │
├───┼─────────┼───────────────┼──────────┤
│ 0 │ nvim    │ /usr/bin/nvim │ external │
╰───┴─────────┴───────────────┴──────────╯./chezmoi --verbose edit ~/.config/starship.toml
chezmoi: warning: /usr/bin/nano /home/pddshk/.local/share/chezmoi/private_dot_config/starship.toml: returned in less than 1s
chezmoi: /usr/bin/nano: fork/exec /usr/bin/nano: no such file or directory

with bash

./chezmoi edit
# runs nvim

Output of chezmoi doctor

Details with zsh or nushell
./chezmoi doctor
RESULT    CHECK                       MESSAGE
warning   version                     dev, commit 6624b49786a9f039f05b4d929c35fd4f4bf17337, built at 2026-03-09T22:45:19Z
warning   latest-version              v2.70.0
ok        os-arch                     linux/amd64 (Solus 4.8)
ok        uname                       Linux solus 6.18.20-332.current #1 SMP PREEMPT_DYNAMIC 2026-03-28 x86_64 GNU/Linux
ok        go-version                  go1.26.1 (gc)
ok        executable                  ~/Programs/chezmoi/chezmoi
ok        upgrade-method              replace-executable
info      config-file                 ~/.config/chezmoi/chezmoi.toml: not 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
error     hardlink                    failed creating hardlink from ~/.local/share/chezmoi to /tmp: link ~/.local/share/chezmoi/.chezmoi-doctor-hardlink-test /tmp/chezmoi-doctor4258239236/.chezmoi-doctor-hardlink-test: invalid cross-device link
ok        symlink                     created symlink from .new-name to .old-name
ok        umask                       002
ok        cd-command                  found /usr/bin/nu
ok        cd-args                     /usr/bin/nu
info      diff-command                not set
failed    edit-command                exec: "/usr/bin/nano": stat /usr/bin/nano: no such file or directory
ok        edit-args                   /usr/bin/nano
ok        git-command                 found /usr/bin/git, version 2.53.0
warning   merge-command               vimdiff not found in $PATH
ok        shell-command               found /usr/bin/nu
ok        shell-args                  /usr/bin/nu
info      age-command                 age not found in $PATH
ok        gpg-command                 found /usr/bin/gpg, version 2.5.18
info      pinentry-command            not set
info      1password-command           op not found in $PATH
info      bitwarden-command           bw not found in $PATH
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
ok        keepassxc-command           found /usr/bin/keepassxc-cli, version 2.7.12
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      protonpass-command          pass-cli 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

with bash

./chezmoi doctor
RESULT    CHECK                       MESSAGE
warning   version                     dev, commit 6624b49786a9f039f05b4d929c35fd4f4bf17337, built at 2026-03-09T22:45:19Z
warning   latest-version              v2.70.0
ok        os-arch                     linux/amd64 (Solus 4.8)
ok        uname                       Linux solus 6.18.20-332.current #1 SMP PREEMPT_DYNAMIC 2026-03-28 x86_64 GNU/Linux
ok        go-version                  go1.26.1 (gc)
ok        executable                  ~/Programs/chezmoi/chezmoi
ok        upgrade-method              replace-executable
info      config-file                 ~/.config/chezmoi/chezmoi.toml: not 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
error     hardlink                    failed creating hardlink from ~/.local/share/chezmoi to /tmp: link ~/.local/share/chezmoi/.chezmoi-doctor-hardlink-test /tmp/chezmoi-doctor3117180100/.chezmoi-doctor-hardlink-test: invalid cross-device link
ok        symlink                     created symlink from .new-name to .old-name
ok        umask                       002
ok        cd-command                  found /usr/bin/nu
ok        cd-args                     /usr/bin/nu
info      diff-command                not set
ok        edit-command                found /usr/bin/nvim
ok        edit-args                   /usr/bin/nvim
ok        git-command                 found /usr/bin/git, version 2.53.0
warning   merge-command               vimdiff not found in $PATH
ok        shell-command               found /usr/bin/nu
ok        shell-args                  /usr/bin/nu
info      age-command                 age not found in $PATH
ok        gpg-command                 found /usr/bin/gpg, version 2.5.18
info      pinentry-command            not set
info      1password-command           op not found in $PATH
info      bitwarden-command           bw not found in $PATH
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
ok        keepassxc-command           found /usr/bin/keepassxc-cli, version 2.7.12
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      protonpass-command          pass-cli 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

I made a fresh build as even though I have installed chezmoi from my package manager, and it claims that version is 2.70.0, I decided to better build it from source at appropriate tag, because from command line

chezmoi --version
chezmoi version dev

which does not help much

Metadata

Metadata

Assignees

No one assigned

    Labels

    supportSupport request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions