Skip to content

Why does my template break? #2208

Answered by twpayne
jfmercer asked this question in Q&A
Jul 12, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

That file begins with {{- if and (eq .chezmoi.os "darwin") (eq .installMacApps true) -}}. I also tried {{- if and (eq .chezmoi.os "darwin") .installMacApps -}}, but no luck.

The problem here is that .installMacApps in the first line of the file is not defined when you run chezmoi init for the first time.

Note also this line:
{{- $installMacApps := eq (promptString "Install Mac applications (y/n)") "y" -}}
is incorrect. The := creates a new $installMacApps variable that is scoped within the if statement. You need:
{{- $installMacApps = eq (promptString "Install Mac applications (y/n)") "y" -}}
instead. Note the := is replaced with =: this modifies the existing $installMacApps variable.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jfmercer
Comment options

Answer selected by jfmercer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants