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

Lines of diff ouput are executed as commands on Windows #4195

Open
LeonardoMor opened this issue Jan 11, 2025 · 2 comments
Open

Lines of diff ouput are executed as commands on Windows #4195

LeonardoMor opened this issue Jan 11, 2025 · 2 comments
Labels
support Support request

Comments

@LeonardoMor
Copy link

Describe the bug

When using any sub-command that involves showing a diff on Windows, each line of the diff is executed as if it was a command, thus showing the lines of the diff along with a bunch of errors.

To reproduce

  1. Modify some file managed by chezmoi.
  2. Run chezmoi diff

Expected behavior

Normal diff output.

Output of command with the --verbose flag

For this, I simple added the line '' some comments here to the _vimrc file. Then I get this output:

chezmoi diff --verbose
Microsoft Windows [Version 10.0.26100.2605]
(c) Microsoft Corporation. All rights reserved.

C:\Users\leomc\.local\share\chezmoi>diff --git a/_vimrc b/_vimrc
'diff' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\leomc\.local\share\chezmoi>index 64d96cef093061a2c6affaff35d7d9d69f1a9ddb..57fe526bc4fcd88f7fa6d4c8200cbb60f5884d58 100666
'index' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\leomc\.local\share\chezmoi>--- a/_vimrc
'---' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\leomc\.local\share\chezmoi>+++ b/_vimrc
'+++' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\leomc\.local\share\chezmoi>@@ -2,3 +2,5 @@ set number
'@@' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\leomc\.local\share\chezmoi> set relativenumber
Environment variable relativenumber not defined

C:\Users\leomc\.local\share\chezmoi> language messages en_US
'language' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\leomc\.local\share\chezmoi>
C:\Users\leomc\.local\share\chezmoi>+
'+' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\leomc\.local\share\chezmoi>+'' some comments here
'+''' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\leomc\.local\share\chezmoi>

Output of chezmoi doctor

chezmoi doctor
RESULT    CHECK                       MESSAGE
ok        version                     v2.57.0, commit 9212b40bac1186ff393da8714579cfdc4816cc20, built at 2024-12-30T15:06:18Z, built by goreleaser
ok        latest-version              v2.57.0
ok        os-arch                     windows/amd64
ok        systeminfo                  Microsoft Windows 11 Home (10.0.26100 N/A Build 26100)
ok        go-version                  go1.23.4 (gc)
ok        executable                  ~/AppData/Local/Microsoft/WinGet/Packages/twpayne.chezmoi_Microsoft.Winget.Source_8wekyb3d8bbwe/chezmoi.exe
ok        upgrade-method              winget-upgrade
ok        config-file                 ~/.config/chezmoi/chezmoi.toml, last modified 2025-01-10T17:51:30-06:00
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        cd-command                  found C:/Program Files/PowerShell/7/pwsh.exe
ok        cd-args                     'C:\\Program Files\\PowerShell\\7\\pwsh.exe' -NoLogo
info      diff-command                not set
ok        edit-command                found C:/Program Files/Neovim/bin/nvim.exe
ok        edit-args                   nvim
ok        git-command                 found C:/Program Files/Git/cmd/git.exe, version 2.47.1
ok        merge-command               found C:/Program Files/Neovim/bin/nvim.exe
ok        shell-command               found C:/Windows/system32/cmd.exe
ok        shell-args                  'C:\\Windows\\system32\\cmd.exe'
info      age-command                 age not found in $PATH
info      gpg-command                 gpg not found in $PATH
info      pinentry-command            not set
ok        1password-command           found ~/AppData/Local/Microsoft/WinGet/Packages/AgileBits.1Password.CLI_Microsoft.Winget.Source_8wekyb3d8bbwe/op.exe, version 2.30.3
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
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

Additional context

I have set pager and cd on my chezmoi config.

This only happens on Windows.

@LeonardoMor
Copy link
Author

LeonardoMor commented Jan 11, 2025

Removing this from .chezmoi.toml.tmpl fixes the issue:

{{- if lookPath "bat" -}}
pager = "bat -pp"
{{ end }}

But then I don't get to use bat. I'm okay with not using it, but it's still a malfunction.

@twpayne twpayne added the support Support request label Jan 14, 2025
@twpayne
Copy link
Owner

twpayne commented Jan 14, 2025

It looks like bat on your computer does not do what you expect it to do. It looks like it's trying to run commands rather than run the modern clone of cat.

What is the output of

chezmoi diff --debug

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Support request
Projects
None yet
Development

No branches or pull requests

2 participants