twpayne / chezmoi

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

Bad character U+002F '/' on template file #3295

Closed x80486 closed 1 year ago

x80486 commented 1 year ago

Description

I configured allowed_signers (for Git) as a template file — using chezmoi version 2.34.0.

After upgrading to version 2.40.3, chezmoi states that: chezmoi: template: private_dot_config/git/readonly_allowed_signers.tmpl:1: bad character U+002F '/'

To Reproduce

Expected Behavior

Provided .git.gitlab.email is configured correctly and ${HOME}/.ssh/gitlab-personal.pub is present, chezmoi status shouldn't display any warning(s).

Output of Command With the --verbose Flag

[x80486@uplink:~]$ chezmoi --verbose status 
chezmoi: template: private_dot_config/git/readonly_allowed_signers.tmpl:1: bad character U+002F '/'

Output of chezmoi doctor

```shell [x80486@uplink:~]$ chezmoi doctor RESULT CHECK MESSAGE ok version v2.40.3, commit 294c2c8bea1d9fda0b14bd029774dc96e066c0cd, built at 2023-10-12T21:11:59Z, built by goreleaser ok latest-version v2.40.3 ok os-arch linux/amd64 (Arch Linux) ok uname Linux uplink 6.1.55-1-lts #1 SMP PREEMPT_DYNAMIC Sat, 23 Sep 2023 16:57:15 +0000 x86_64 GNU/Linux ok go-version go1.21.3 (gc) ok executable ~/.local/share/rtx/installs/chezmoi/2.40.3/bin/chezmoi ok upgrade-method replace-executable ok config-file ~/.config/chezmoi/chezmoi.yaml, last modified 2023-10-18T09:23:54-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 ok umask 022 ok cd-command found /bin/bash ok cd-args /bin/bash info diff-command not set ok edit-command found /usr/bin/nano ok edit-args /usr/bin/nano ok git-command found ~/.nix-profile/bin/git, version 2.42.0 warning merge-command vimdiff not found in $PATH ok shell-command found /bin/bash ok shell-args /bin/bash info age-command age not found in $PATH ok gpg-command found /usr/bin/gpg, version 2.2.41 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 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

N/A

halostatue commented 1 year ago
  • Place the following content {{.git.gitlab.email}} namespaces=git {{include .chezmoi.homeDir/.ssh/gitlab-personal.pub | trim}}

The error is correct. Instead, do:

{{ .git.gitlab.email }} namespaces=git {{ include (joinPath .chezmoi.homeDir ".ssh/gitlab-personal.pub") | trim }}

You need to quote paths, and you can’t just concatenate variables and strings that way in Go templates (which is what chezmoi uses).

x80486 commented 1 year ago

Interesting. It works that way. Now I don't understand how it worked before 😑

Thanks for the solution! :1st_place_medal:

By the way, really awesome tool! :bowing_man: