twpayne / chezmoi

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

Including a file adds an extra "<feff>" (BOM) character at the beginning #2693

Closed OrbitalHustler closed 1 year ago

OrbitalHustler commented 1 year ago

Describe the bug

Including a file in another file adds an unwanted character as the first character of the include block.

To reproduce

Create ./test: {{ include "toinclude" }}

Create ./toinclude echo "abcd"

Run chezmoi apply and open ~/test in vim :

image

Expected behavior

No extra character added.

Output of chezmoi doctor

```console RESULT CHECK MESSAGE ok version v2.29.1, commit 5e7063ec11bb85efcf8e0c152dcd7dd674ed2d90, built at 2023-01-02T15:50:04Z, built by goreleaser ok latest-version v2.29.1 ok os-arch linux/amd64 (Debian GNU/Linux 11 (bullseye)) ok uname Linux LAPTOP 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 GNU/Linux ok go-version go1.19.4 (gc) ok executable ~/.local/bin/chezmoi ok upgrade-method replace-executable ok config-file ~/.config/chezmoi/chezmoi.yaml, last modified 2022-06-19T08:22:35-04: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 warning umask 077 ok cd-command found /bin/zsh ok cd-args /bin/zsh 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.30.2 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 ok gpg-command found /usr/bin/gpg, version 2.2.27 info pinentry-command not set info 1password-command op not found in $PATH info bitwarden-command bw 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 vault-command vault not found in $PATH info secret-command not set ```
bradenhilton commented 1 year ago

You mean ~/.local/share/chezmoi/test.tmpl correct?

Can you diff ~/test and ~/.local/share/chezmoi/toinclude to confirm?

OrbitalHustler commented 1 year ago

You mean ~/.local/share/chezmoi/test.tmpl correct?

Yes

Can you diff ~/test and ~/.local/share/chezmoi/toinclude to confirm?

(ins)~/.../share/chezmoi$ diff ~/test toinclude
1,2c1
< echo "abcd"
<
---
echo "abcd"
twpayne commented 1 year ago

These Unicode BOMs are added by some programs on Windows. chezmoi does not use them. You need to remove them from your files.

OrbitalHustler commented 1 year ago

Oh indeed, the files were UTF8 BOM format... Sorry for wasting you time, and thanks