twpayne / chezmoi

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

.chezmoi.config.destDir is not a string #3602

Closed ErrrorMaxx closed 8 months ago

ErrrorMaxx commented 8 months ago

Describe the bug

I think this is a odd, but I can't directly do string operations on .chezmoi.config.destDir. While it looks like a string, it is not allowed in string functions.

I currently use cat .chezmoi.config.destDir as a workaround

To reproduce

$ chezmoi execute-template '{{ .chezmoi.config.destDir | replace "abc" "def" }}'

Expected behavior

No error should happen

Output of command with the --verbose flag

$ chezmoi --verbose execute-template '{{ .chezmoi.config.destDir | replace "abc" "def" }}'
chezmoi: template: arg1:1:43: executing "arg1" at <"def">: wrong type for value; expected string; got chezmoi.AbsPath

Output of chezmoi doctor

```console $ chezmoi doctor RESULT CHECK MESSAGE ok version v2.47.0, commit 39bd915f446068862cc3064edb6dbeee795785ca, built at 2024-02-25T20:56:37Z, built by goreleaser failed latest-version Get "https://api.github.com/repos/twpayne/chezmoi/releases/latest": dial tcp: lookup api.github.com on [::1]:53: read udp [::1]:58604->[::1]:53: read: connection refused ok os-arch android/arm64 ok uname Linux localhost 4.19.191+ #1 SMP PREEMPT Wed Nov 29 21:44:22 CST 2023 aarch64 Android ok go-version go1.22.0 (gc) ok executable ~/.local/bin/chezmoi ok upgrade-method replace-executable ok config-file ~/.config/chezmoi/chezmoi.yaml, last modified 2024-02-27T05:30:09Z ok source-dir ~/.local/share/chezmoi/home is a directory 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 /data/data/com.termux/files/usr/bin/zsh ok cd-args /data/data/com.termux/files/usr/bin/zsh info diff-command not set ok edit-command found /data/data/com.termux/files/usr/bin/micro ok edit-args micro ok git-command found /data/data/com.termux/files/usr/bin/git, version 2.44.0 warning merge-command vimdiff not found in $PATH ok shell-command found /data/data/com.termux/files/usr/bin/zsh ok shell-args /data/data/com.termux/files/usr/bin/zsh info age-command age not found in $PATH ok gpg-command found /data/data/com.termux/files/usr/bin/gpg, version 2.4.4 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 ```
twpayne commented 8 months ago

Thanks for reporting this. The underlying problem is that replace is a template function from github.com/masterminds/sprig and pretty much all the functions in masterminds/sprig are inflexible and broken. See #2668 for work on a replacement.

3609 adds a hacky work-around.