Closed davidolrik closed 3 years ago
I'm unable to reproduce this either with my own dotfiles or with a test (#1214).
Could you share a way to reproduce this?
I will try to create a small test case that exhibits the problem.
The weird thing is, that it's not all templates that can't access the variables. E.g. my Scratch that, that was me not cleaning up everything between runs..gitconfig
also uses data under me
and that is interpolated in the first go.
If I understand correctly, this is now fixed. Please re-open if needed. Thanks!
No, I still have the issue - I just thought it was only some of the templates that couldn't access the variables, when it is in fact all of them.
Any update on a way of reproducing this?
Sorry haven't had the time before now, luckily it was quite easy to reproduce.
Here is a very small dotfile repo that exhibits the error: https://github.com/davidolrik/chezmoi-bug.git
And here is the output of a run from a clean state:
sh -c "$(curl -fsLS git.io/chezmoi)" -- init --apply https://github.com/davidolrik/chezmoi-bug.git
info found version 2.0.13 for latest/linux/amd64
info installed ./bin/chezmoi
Cloning into '/home/test/.local/share/chezmoi'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 6 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), 1.28 KiB | 654.00 KiB/s, done.
chezmoi: template: dot_envrc.tmpl:3:18: executing "dot_envrc.tmpl" at <.me.fullname>: map has no entry for key "me"
$ cat .envrc
cat: .envrc: No such file or directory
$ sh -c "$(curl -fsLS git.io/chezmoi)" -- init --apply https://github.com/davidolrik/chezmoi-bug.git
info found version 2.0.13 for latest/linux/amd64
info installed ./bin/chezmoi
$ cat .envrc
#!/usr/bin/env bash
export name=David Jack Wange Olrik
export email=david.personal@example.com
export signingkey=ECC395B798725570D8699DCB5B3BAADEDDEE156E
Thanks for the reproduction case - I see what's happening now.
The config file template needs to be called .chezmoi.toml.tmpl
in the source directory, not dot_config/chezmoi/chezmoi.toml.tmpl
.
Ah, I see – I just a chezmoi add --template ~/.config/chezmoi/chezmoi.toml
.
Maybe this could be intercepted, and turned into .chezmoi.toml.tmpl
?
Maybe this could be intercepted, and turned into
.chezmoi.toml.tmpl
?
In practice, I think this would be really tricky to intercept. ~/.config/chezmoi/chezmoi.toml
happens to be the default config file location, but this is fully customizable based on the XDG base directory specification and can also be overridden with the --config
command line flag.
I think this issue is now resolved, please re-open if needed.
Upon first run of
sh -c "$(curl -fsLS git.io/chezmoi)" -- init davidolrik --apply
I get the following template error:dot_config/private_hub.tmpl
contains this:and my
chezmoi.toml.tmpl
has a section with the referenced variable:After the first run, the contents of
chezmoi.toml
is correct, and a second run installs thedot_config/private_hub.tmpl
as expected.So it seems that the
chezmoi.toml
is generated correctly, but not reloaded / made available to other templates during the firstinit
.