Closed youtux closed 8 months ago
You need to use .chezmoi.$FORMAT.tmpl
. In your case it would be .chezmoi.toml.tmpl
.
You can use your existing config by simply moving/renaming it.
Running chezmoi init
will execute this template and generate a config.
shouldn't then I be able to run chezmoi add --template ~/.config/chezmoi/chezmoi.toml
?
It still gives me the same error. If this is an allowed way, why would chezomoi not allow that operation?
That command would create ~/.local/share/chezmoi/dot_config/chezmoi/chezmoi.toml.tmpl
which is still incorrect.
We prevent this because allowing this means that any changes you make to your config would always be one chezmoi apply
behind the rest of your dotfiles.
You can move ~/.config/chezmoi/chezmoi.toml
to ~/.local/share/chezmoi/.chezmoi.toml.tmpl
then run chezmoi init
.
Every time you change your config template you must also run chezmoi init
to regenerate your config.
I wish the docs would describe this specific use case, it was not immediate to me how this works.
For posterity, I solved the issue running the following:
mv ~/.config/chezmoi/chezmoi.toml "$(chezmoi source-path)/.chezmoi.toml.tmpl"
chezmoi apply
chezmoi init
They do:
.chezmoi.$FORMAT.tmpl
chezmoi init
If you have some suggestions for improving the documentation to make this easier to find, we will happily accept either pull requests or new issues with those suggestions. But it is in the documentation.
We do request that people search all issues before opening a new one, as a closely related question was asked two days ago (#3634), which has pointers to #3405, #2854, and #3285—the latter two of which have the text from the error in their title and/or body.
Ah sorry, I only used google assuming it would have indexed issues with that string. What I was suggesting was to add this to a more visible place in the docs, like the FAQs, since this seem to be a frequently asked question :) maybe even including this error message for better indexing.
Or, why not allowing that file to be just added to the dotfiles, since one can already workaround it by adding the .chezmoi.toml.tmpl?
Ah sorry, I only used google assuming it would have indexed issues with that string. What I was suggesting was to add this to a more visible place in the docs, like the FAQs, since this seem to be a frequently asked question :) maybe even including this error message for better indexing.
Or, why not allowing that file to be just added to the dotfiles, since one can already workaround it by adding the .chezmoi.toml.tmpl?
The issues linked above have the reasons why this cannot be resolved, but https://github.com/twpayne/chezmoi/issues/3405#issuecomment-1852470433 (and probably other linked issues) explains why it has to be handled differently.
got it. One last suggestion then: maybe it would be worth to have the error message from chezmoi add ~/.config/chezmoi/chezmoi.toml
would link to the page that explains how to add chezmoi config to the tracked dotfiles.
One last suggestion then: maybe it would be worth to have the error message from
chezmoi add ~/.config/chezmoi/chezmoi.toml
Good idea. Implemented in #3644. I've used text instead of a URL (as the URL might change over time), but the text should be a sufficient clue for future users.
That entire chezmoi
directory should be removed.
@twpayne do we not also protect against chezmoi add */.chezmoiignore
?
@twpayne do we not also protect against
chezmoi add */.chezmoiignore
?
Not at the moment. At the moment, chezmoi protects against adding files in its config (~/.config/chezmoi
), state (~/.local/share/chezmoi
), and cache (~/.cache/chezmoi
) directories. .chezmoiignore
files have no effect outside of chezmoi's state.
What exactly are you trying to do?
I made a config file so that every edit I make is autocommited and pushed. I would like to have this configuration apply to all the machines I use.
What have you tried so far?
I tried to add the config file to chezmoi, but it complains saying it's protected:
Where else have you checked for solutions?
Output of any commands you've tried with
--verbose
flagOutput of
chezmoi doctor
Additional context
Add any other context about the problem here.