chezmoi
chezmoi copied to clipboard
2 chezmoi's with 2 configs. commandline config ignored
Describe the bug
When 2 chezmoi on same system, commandline config is ignored. Doctor:
failed config-file found ~/.config/chezmoi/chezmoi.toml, expected /media/Dane/.chezmoi/chezmoi.toml
To reproduce
use chezmoi
for your home ~
directory and
created .bashrc
alias:
alias dchezmoi="chezmoi --destination /media/Dane --source /media/Dane/.chezmoi/data --working-tree /media/Dane/.chezmoi/data --config /media/Dane/.chezmoi/chezmoi.toml"
configs:
marcin@pc:/media/Dane$ cat /media/Dane/.chezmoi/chezmoi.toml
mode = "symlink"
marcin@pc:/media/Dane$ cat ~/.config/chezmoi/chezmoi.toml
[git]
autoCommit = true
autoPush = true
[diff]
command = "kdiff3"
[merge]
command = "kdiff3"
Expected behavior
alias dchezmoi
should use commandline configfile: /media/Dane/.chezmoi/chezmoi.toml
Output of chezmoi doctor
marcin@pc:/media/Dane$ dchezmoi doctor
RESULT CHECK MESSAGE
ok version v2.15.2, commit bf0c9bee555f1de78cd003638621fff375a26867, built at 2022-05-01T13:19:59Z, built by goreleaser
ok latest-version v2.15.2
ok os-arch linux/amd64 (Ubuntu 20.04.4 LTS (Focal Fossa))
ok uname Linux pc 5.13.0-40-generic #45~20.04.1-Ubuntu SMP Mon Apr 4 09:38:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
ok go-version go1.18.1 (gc)
ok executable /snap/chezmoi/407/chezmoi
ok upgrade-method snap-refresh
failed config-file found ~/.config/chezmoi/chezmoi.toml, expected /media/Dane/.chezmoi/chezmoi.toml
ok source-dir /media/Dane/.chezmoi/data is a directory
ok suspicious-entries no suspicious entries
ok working-tree /media/Dane/.chezmoi/data is a directory
ok dest-dir /media/Dane is a directory
ok shell-command found /bin/bash
ok shell-args /bin/bash
ok cd-command found /bin/bash
ok cd-args /bin/bash
ok edit-command found /usr/bin/atom
ok edit-args /usr/bin/atom
info diff-command not set
ok umask 002
ok git-command found /usr/bin/git, version 2.25.1
warning merge-command vimdiff not found in $PATH
info age-command age not found in $PATH
ok gpg-command found /usr/bin/gpg, version 2.2.19
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 lastpass-command lpass not found in $PATH
info pass-command pass not found in $PATH
info vault-command vault not found in $PATH
info secret-command not set
marcin@pc:/media/Dane$
Additional context
Add any other context about the problem here.
I believe that this is only a problem with this line of the doctor
command. chezmoi does use the config file specified by --config
for all other commands. Can you confirm this?
chezmoi does use the config file specified by --config for all other commands. Can you confirm this?
from what I see it looks it doesn't.
my config for dchezmoi
alias is to use symlinks:
marcin@pc:/media/Dane$ cat /media/Dane/.chezmoi/chezmoi.toml
mode = "symlink"
marcin@pc:/media/Dane$
I'm adding a file:
marcin@pc:/media/Dane$ dchezmoi init
marcin@pc:/media/Dane$ dchezmoi status
marcin@pc:/media/Dane$ dchezmoi add IN\ CASE\ OF\ FOUND.txt
marcin@pc:/media/Dane$ dchezmoi status
M IN CASE OF FOUND.txt
marcin@pc:/media/Dane$
File has been added but niether source nor destanation is a symlnk
marcin@pc:/media/Dane$ ll IN\ CASE\ OF\ FOUND.txt
-rw-rw-r-- 1 marcin marcin 217 lip 31 2015 'IN CASE OF FOUND.txt'
marcin@pc:/media/Dane$ ll /media/Dane/.chezmoi/data/IN\ CASE\ OF\ FOUND.txt
-rw-rw-r-- 1 marcin users 217 maj 2 22:06 '/media/Dane/.chezmoi/data/IN CASE OF FOUND.txt'
marcin@pc:/media/Dane$
I'm still unable to reproduce this. Do you have an example that demonstrates the problem on a clean system?
I have a similar problem with 2 config files that I believe to be related/identical to this one.
I am using the command chezmoi
with the default config file (i.e. ~/.config/chezmoi/chezmoi.toml
) and another one chezmoik
as an alias:
chezmoi --source ~/.local/share/chezmoi-kodi --config ~/.config/chezmoi/chezmoi-kodi.toml
chezmoi doctor (default config - no extra config file parameter)
RESULT CHECK MESSAGE
warning version v2.18.1, built at 2022-06-23T20:04:43Z
ok latest-version v2.18.1
ok os-arch linux/amd64 (Manjaro Linux)
ok uname Linux jannik-desktop 5.15.50-1-MANJARO #1 SMP PREEMPT Sun Jun 26 07:06:30 UTC 2022 x86_64 GNU/Linux
ok go-version go1.18.3 (gc)
ok executable /usr/bin/chezmoi
ok config-file ~/.config/chezmoi/chezmoi.toml, last modified 2022-07-08T10:39:31+02:00
warning source-dir ~/.local/share/chezmoi is a git working tree (dirty)
warning suspicious-entries ~/.local/share/chezmoi/dot_config/chezmoi/chezmoi.toml
warning working-tree ~/.local/share/chezmoi is a git working tree (dirty)
ok dest-dir ~ is a directory
ok shell-command found /usr/bin/fish
ok shell-args /usr/bin/fish
ok cd-command found /usr/bin/fish
ok cd-args /usr/bin/fish
ok edit-command found /usr/bin/nvim
ok edit-args /usr/bin/nvim
info diff-command not set
ok umask 022
ok git-command found /usr/bin/git, version 2.37.0
ok merge-command found /usr/bin/vimdiff
ok age-command found /usr/bin/age, version 1.0.0
ok gpg-command found /usr/bin/gpg, version 2.2.35
info pinentry-command not set
ok 1password-command found /usr/bin/op, version 2.5.1
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 keeper-command keeper not found in $PATH
info keepassxc-db not set
info lastpass-command lpass not found in $PATH
info pass-command pass not found in $PATH
info vault-command vault not found in $PATH
info secret-command not set
chezmoik doctor (config file: ~/.config/chezmoi/chezmoi-kodi.toml)
RESULT CHECK MESSAGE
warning version v2.18.1, built at 2022-06-23T20:04:43Z
ok latest-version v2.18.1
ok os-arch linux/amd64 (Manjaro Linux)
ok uname Linux jannik-desktop 5.15.50-1-MANJARO #1 SMP PREEMPT Sun Jun 26 07:06:30 UTC 2022 x86_64 GNU/Linux
ok go-version go1.18.3 (gc)
ok executable /usr/bin/chezmoi
failed config-file found ~/.config/chezmoi/chezmoi.toml, expected ~/.config/chezmoi/chezmoi-kodi.toml
warning source-dir ~/.local/share/chezmoi-kodi is a git working tree (dirty)
ok suspicious-entries no suspicious entries
warning working-tree ~/.local/share/chezmoi-kodi is a git working tree (dirty)
ok dest-dir ~ is a directory
ok shell-command found /usr/bin/fish
ok shell-args /usr/bin/fish
ok cd-command found /usr/bin/fish
ok cd-args /usr/bin/fish
ok edit-command found /usr/bin/nvim
ok edit-args /usr/bin/nvim
info diff-command not set
ok umask 022
ok git-command found /usr/bin/git, version 2.37.0
ok merge-command found /usr/bin/vimdiff
ok age-command found /usr/bin/age, version 1.0.0
ok gpg-command found /usr/bin/gpg, version 2.2.35
info pinentry-command not set
ok 1password-command found /usr/bin/op, version 2.5.1
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 keeper-command keeper not found in $PATH
info keepassxc-db not set
info lastpass-command lpass not found in $PATH
info pass-command pass not found in $PATH
info vault-command vault not found in $PATH
info secret-command not set
My exact problem is:
I run chezmoik init
to set up my ~/.config/chezmoi/chezmoi-kodi.toml
config file, but the final content will be written to chezmoi.toml
instead (from my understanding, this should be in chezmoi-kodi.toml
- as specified with my alias).
This can be easily reproduced:
- Have an empty directory of
~/.config/chezmoi/
(not required, but helps to clearly see what happens) - Clone chezmoi dotfiles repo to
~/.local/share/chezmoi-non-default-dir
- Have some arbitrary content in
~/.local/share/chezmoi-non-default-dir/.chezmoi.toml.tmpl
- Run
chezmoi --source ~/.local/share/chezmoi-non-default-dir --config ~/.config/chezmoi/chezmoi-non-default-config.toml init
- The
init
output is now stored at~/.config/chezmoi/chezmoi.toml
(<- this should be~/.config/chezmoi/chezmoi-non-default-config.toml
though?)
Further notes:
If i manually rename the output from chezmoi.toml
to chezmoi-kodi.toml
, all template data at [data] is recognized fine when using template data with the alias command chezmoik
.
If this is not related to this issue I am happy to open a new one and provide additional details if required.
My exact problem is:
I run
chezmoik init
to set up my~/.config/chezmoi/chezmoi-kodi.toml
config file, but the final content will be written tochezmoi.toml
instead (from my understanding, this should be inchezmoi-kodi.toml
- as specified with my alias).
For this you need to use the --config-path
flag to chezmoi init
.
Since there is no reproduction case for the original issue, I'll close this now.