twpayne / chezmoi

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

.chezmoiexternal excludes not working on windows? #2890

Closed alkuzad closed 1 year ago

alkuzad commented 1 year ago

Describe the bug

I have excludes defined and on test flox/nix environment they work but on Windows they dont

To reproduce

Setup .chezmoiexternal.toml:

["AppData/Local/clink/includes/clink-completions"]
type = "archive"
url = "https://github.com/vladimir-kotikov/clink-completions/archive/master.tar.gz"
#exact = true
stripComponents = 1
#refreshPeriod = "168h"
exclude = ["**/.github", "**/.vscode", "**/git.lua"]

Run chezmoi apply and see that files excluded are created.

Expected behavior

.github, .vscode folders and git.lua are skipped

Output of command with the --verbose flag

There is no point of pushing big diffs so just the file diff part:

diff --git a/AppData/Local/clink/includes/clink-completions/git.lua b/AppData/Local/clink/includes/clink-completions/git.lua
new file mode 100666
index 0000000000000000000000000000000000000000..6003634220e947da56b9187b122030e2e6f4e8a1
--- /dev/null
+++ b/AppData/Local/clink/includes/clink-completions/git.lua

Output of chezmoi doctor

RESULT CHECK MESSAGE ok version v2.33.0, commit ced12b81b493670520b177dcc62de2c67172858d, built at 2023-03-24T01:29:01Z, built by goreleaser ok latest-version v2.33.0 ok os-arch windows/amd64 ok systeminfo Microsoft Windows 10 Enterprise (10.0.19042 N/A Build 19042) ok go-version go1.20.2 (gc) ok executable ~/scoop/apps/chezmoi/current/chezmoi.exe ok upgrade-method replace-executable ok config-file ~/.config/chezmoi/chezmoi.toml, last modified 2022-12-30T17:29:31+01:00 ok source-dir ~/.local/share/chezmoi is a git working tree (clean) ok suspicious-entries no suspicious entries ok working-tree ~/.local/share/chezmoi is a git working tree (clean) ok dest-dir ~ is a directory ok cd-command found C:/Windows/system32/cmd.exe ok cd-args 'C:\\Windows\\system32\\cmd.exe' info diff-command not set ok edit-command found ~/AppData/Local/Programs/Microsoft VS Code/bin/code.cmd ok edit-args code.cmd ok git-command found ~/scoop/shims/git.exe, version 2.40.0 ok merge-command found ~/AppData/Local/Programs/Microsoft VS Code/bin/code.cmd 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 ok gpg-command found ~/scoop/apps/gpg/current/bin/gpg.exe, version 2.4.0 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

I created same file on test env on Flox, and changed the path of external to just "clink-completions" and it works on Linux, so I don't know how to debug:

docker run --rm -it ghcr.io/flox/flox@sha256:88cb7a954b326ecf6f85a49add865eb4807b1a10e580ef61ed0df0181bb992ba

flox install unstable.nixpkgs-flox.chezmoi@2.32.0
flox activate

chezmoi init 
cd ~/.local/share/chezmoi/
vim .chezmoiexternal.toml

Edit file into:

["clink-completions"]
type = "archive"
url = "https://github.com/vladimir-kotikov/clink-completions/archive/master.tar.gz"
#exact = true
stripComponents = 1
#refreshPeriod = "168h"
exclude = ["**/.github", "**/.vscode", "**/git.lua"]

And run:

chezmoi apply

On linux container it works fine.

twpayne commented 1 year ago

I tried to reproduce this on Windows in 1cfc293000a129f72719c680b0715d37b586ebb7, but the excludes behaved as expected.

Can you share the contents of your dotfiles repo? Alternatively, do you have an example that reproduces this problem on a new machine?

alkuzad commented 1 year ago

@twpayne I tried to reproduce it on another PC and it did work fine. I have a suspicion that AntiVirus does something shady as chezmoi is running super slow (over 1m sometimes to do apply) on this PC (I checked on Performance Analyzer and not because of chezmoi itself).

I think I managed to do a local VM with Windows to have easier way of doing isolated tests :D Sadly not everything is on WSL yet, but I want to get there eventually.

Sorry for troubles, at least one more test is to guard against regression in future.