twpayne / chezmoi

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

Error in documentation? #2867

Closed agingorange closed 1 year ago

agingorange commented 1 year ago

Describe the bug

In the documentation there is an example on how to Combine operating system and Linux distribution conditionals. The code posted returns an error.

To reproduce

Put the following in ~/.config/chezmoi/chezmoi.toml as described in the manual:

{{- $osid := .chezmoi.os -}}
{{- if hasKey .chezmoi.osRelease "id" -}}
{{-   $osid = printf "%s-%s" .chezmoi.os .chezmoi.osRelease.id -}}
{{- end -}}

[data]
    osid = {{ $osid | quote }}

Running a chezmoi command returns the following:

chezmoi: invalid config: /Users/username/.config/chezmoi/chezmoi.toml: toml: invalid character at start of key: {

Expected behavior

A working template variable.

Output of command with the --verbose flag

$ chezmoi --verbose $COMMAND

Same as above.

Output of chezmoi doctor

```console $ chezmoi doctor ``` RESULT CHECK MESSAGE warning version v2.31.1, built by nixpkgs warning latest-version v2.32.0 ok os-arch darwin/arm64 ok uname Darwin thessia.home 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:39:35 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T8103 arm64 ok go-version go1.19.6 (gc) ok executable ~/.nix-profile/bin/chezmoi ok upgrade-method replace-executable error config-file ~/.config/chezmoi/chezmoi.toml: ~/.config/chezmoi/chezmoi.toml: toml: invalid character at start of key: { 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 umask 022 ok cd-command found /bin/zsh ok cd-args /bin/zsh info diff-command not set ok edit-command found ~/.nix-profile/bin/nvim ok edit-args ~/.nix-profile/bin/nvim ok git-command found ~/.nix-profile/bin/git, version 2.39.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 ~/.nix-profile/bin/gpg, version 2.3.7 info pinentry-command not set ok 1password-command found /usr/local/bin/op, version 2.14.0 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

Put the following in ~/.config/chezmoi/chezmoi.toml as described in the manual:

That isn't what is described in the manual:

Put the following in your configuration file template:

You are using template syntax outside of a template.

https://www.chezmoi.io/reference/special-files-and-directories/chezmoi-format-tmpl/

https://www.chezmoi.io/user-guide/setup/#create-a-config-file-on-a-new-machine-automatically https://www.chezmoi.io/user-guide/setup/#re-create-your-config-file

agingorange commented 1 year ago

Oh, wow, that's selective reading for ya. Thanks for pointing me to my error.