twpayne / chezmoi

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

Chezmoi to control asdf .tool-versions file #2849

Closed Pilgrim1379 closed 1 year ago

Pilgrim1379 commented 1 year ago

What exactly are you trying to do?

Asdf version manager automatically modifies ~/.tool-versions anytime you install or delete a package. At the moment anytime this happens I have to re-add otherwise chezmoi apply overwrites the content.

What have you tried so far?

I have followed the instructions under manage different types of file.

What I was expecting was a symlink to be created at ~/.tool-versions which points to the actual file in chezmoi sourceDir. However no symlink is created.

In ~/.local/share/chezmoi I have the file .tool-versions this contains:

python 3.11.2
java jdk-17.0.6+10
erlang 25.3
elixir 1.14.3-otp-25

and symlink_dot_tool-versions.tmpl whose content is:

{{ .chezmoi.sourceDir }}/.tool-versions

Where else have you checked for solutions?

Output of chezmoi doctor

```console $ chezmoi doctor RESULT CHECK MESSAGE ok version v2.31.1, commit b53467c8cc56e46ef848624193b753c927b89689, built at 2023-03-01T09:50:00Z, built by Homebrew ok latest-version v2.31.1 ok os-arch darwin/amd64 ok uname Darwin MacBook-Pro.local 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:42:11 PST 2023; root:xnu-8792.81.3~2/RELEASE_X86_64 x86_64 ok go-version go1.20.1 (gc) ok executable /usr/local/bin/chezmoi ok upgrade-method replace-executable ok config-file ~/.config/chezmoi/chezmoi.toml, last modified 2023-02-02T10:53:03Z warning source-dir ~/.local/share/chezmoi is a git working tree (dirty) warning suspicious-entries ~/.local/share/chezmoi/private_dot_config/chezmoi/chezmoi.toml warning working-tree ~/.local/share/chezmoi is a git working tree (dirty) ok dest-dir ~ is a directory ok umask 022 ok cd-command found /usr/local/bin/zsh ok cd-args /usr/local/bin/zsh info diff-command not set ok edit-command found /usr/local/bin/code ok edit-args code --wait ok git-command found /usr/local/bin/git, version 2.39.2 ok merge-command found /usr/bin/vimdiff ok shell-command found /usr/local/bin/zsh ok shell-args /usr/local/bin/zsh info age-command age not found in $PATH ok gpg-command found /usr/local/bin/gpg, version 2.4.0 info pinentry-command not set info 1password-command op not found in $PATH info bitwarden-command bw 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 vault-command vault not found in $PATH info secret-command not set ```

Not sure what I'm doing wrong as the example provided seemed straight forward enough.

twpayne commented 1 year ago

Looking at the source state of .tool-versions in your dotfiles repo, it is a file dot_tool-versions, not symlink_dot_tool-versions.tmpl.

Could you push the changes to your dotfiles so I can investigate?

Pilgrim1379 commented 1 year ago

@twpayne I've just pushed the changes. Thanks

twpayne commented 1 year ago

Ah, chezmoi is ignoring .tool-versions completely as it it's in your .chezmoiignore.

Pilgrim1379 commented 1 year ago

Thanks @twpayne it's working now. The decision to put it in .chezmoiignore came from the example as below:

Tell chezmoi to ignore this file:

$ echo settings.json >> $(chezmoi source-path)/.chezmoiignore

Thanks again. I'll close this in a bit.

twpayne commented 1 year ago

The decision to put it in .chezmoiignore came from the example as below:

Tell chezmoi to ignore this file:

$ echo settings.json >> $(chezmoi source-path)/.chezmoiignore

Ah-hah! Thank you for the explanation. This is only needed in the settings.json example as settings.json does not begin with a .. chezmoi ignores all files beginning with a . in the source directory (except for .chezmoi* files) so the addition to .chezmoiignore is not needed in the .asdf-versions case. I'll update the docs.