Closed PebcakCity closed 8 months ago
The presence of # …
does not mean anything to go templates. If you want to put comments like that, you will need to either use (a) a delimiter directive, (b) template them out ({{ "{{" }}- template "basic.tmpl" . -}}
), (c) escape them ({\{- template "basic.tmpl" -}}
), or (d) fake them out ([[- template "basic.tmpl" -]]
).
This is probably only visible on Windows because of the {{ if eq .chezmoi.os "windows" }}
at the beginning. While Go templates more or less parse everything, they do so "opportunistically", so that if an if condition prevents template replacements from being seen, it will not be executed.
Understood, thanks for the info.
Describe the bug
In my
.chezmoiignore
, I have comments I included that outline a series of steps I needed to take to have certain files be located in different directories on different systems. These comment lines all begin with '#' like ordinary comments. When one or more of the comment lines looks like this:... this apparently causes Chezmoi to actually include
.chezmoitemplates/bashrc.tmpl
at that location and process it as if it's part of.chezmoiignore
. When trying to runchezmoi apply
orchezmoi diff
, I get errors like:(My .chezmoiignore isn't even 64 lines long, it's actually 52 including all the comments. But I have a function defined in my
.chezmoitemplates/bashrc.tmpl
file calledprepend_to_path
that lets me easily prepend directories to my path. Chezmoi apparently includesbashrc.tmpl
and tries to process its lines as if they're ignore patterns ala .gitignore/.chezmoiignore.)To reproduce
.chezmoitemplates
calledbashrc.tmpl
that is a template for a.bashrc
file.chezmoiignore
file, place a comment like# {{- template "bashrc.tmpl" . -}}
chezmoi diff
Expected behavior
Comments, including those with
{{- template ... -}}
should be ignoredOutput of command with the
--verbose
flagOutput of
chezmoi doctor
Additional context
This only seems to happen on Windows? When I remove these "template" comments, it runs correctly. It took a while for me to figure out what was causing these errors. When I inserted a similar comment into my
.chezmoiignore
file on a Mac, it did not seem to affect it. I'm using this roundabout method for keepingbashrc
in different locations because on my Linux and Mac systems, I keepbashrc
in.config/bash
. But I'm running Cygwin on Windows and it's ... different. Doesn't handle symlinks too well so I gave up on trying to tame it into being XDG compliant.Below is the section of my
.chezmoiignore
that temporarily broke my Chezmoi's brain:Thank you for Chezmoi, it's awesome! Keep up the good work.