twpayne / chezmoi

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

.chezmoiroot ignored by source-path in v2.23.0 #2380

Closed jrmcdonald closed 1 year ago

jrmcdonald commented 1 year ago

Describe the bug

When upgrading to v2.23.0 from v2.22.1 the directory specified in .chezmoiroot is ignored when the chezmoi source-path command is run.

For example if my .chezmoiroot contents are as follows:

home

In v2.22.1 the chezmoi source-path command returns:

/home/jamie/.local/share/chezmoi/home

Whereas in v2.23.0 the same command returns:

/home/jamie/.local/share/chezmoi

To reproduce

I reproduced this using a clean ubuntu docker image.

Basic setup steps:

docker run -it ubuntu /bin/bash
apt update && apt install curl -y
adduser --disabled-password --gecos "" jamie
su - jamie

v2.22.1:

sh -c "$(curl -fsSL https://git.io/chezmoi)" -- -b "$HOME/.local/bin" -t "v2.22.1" init jrmcdonald
.local/bin/chezmoi source-path

v2.23.0:

sh -c "$(curl -fsSL https://git.io/chezmoi)" -- -b "$HOME/.local/bin" -t "v2.23.0" init jrmcdonald
.local/bin/chezmoi source-path

Expected behavior

I would expect the .chezmoiroot definition to be respected by the source-path command.

Output of command with the --verbose flag

source-path has no verbose output as far as I can tell.

Output of chezmoi doctor

v2.22.1 ```console RESULT CHECK MESSAGE ok version v2.22.1, commit 64b9c1fa7346526c17d5073827fe055dc46f6c09, built at 2022-09-04T23:00:07Z, built by goreleaser warning latest-version v2.23.0 ok os-arch linux/amd64 (Ubuntu 22.04.1 LTS (Jammy Jellyfish)) ok uname Linux 9d8b105e16c6 5.15.0-48-generic #54-Ubuntu SMP Fri Aug 26 13:26:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux ok go-version go1.19 (gc) ok executable ~/.local/bin/chezmoi ok upgrade-method replace-executable ok config-file ~/.config/chezmoi/chezmoi.toml, last modified 2022-09-23T13:50:27Z error source-dir ~/.local/share/chezmoi is a git working tree (error) ok suspicious-entries no suspicious entries error working-tree ~/.local/share/chezmoi is a git working tree (error) ok dest-dir ~ 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 warning edit-command vi not found in $PATH ok edit-args vi info diff-command not set ok umask 002 warning git-command git not found in $PATH warning merge-command vimdiff not found in $PATH info age-command age not found in $PATH info gpg-command gpg not found in $PATH 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 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 ``` v2.23.0 ```console RESULT CHECK MESSAGE ok version v2.23.0, commit 7481b57f40c89a777e1f13be3e1d418a8b4f5a16, built at 2022-09-19T01:34:45Z, built by goreleaser ok latest-version v2.23.0 ok os-arch linux/amd64 (Ubuntu 22.04.1 LTS (Jammy Jellyfish)) ok uname Linux 6210623b1b70 5.15.0-48-generic #54-Ubuntu SMP Fri Aug 26 13:26:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux ok go-version go1.19.1 (gc) ok executable ~/.local/bin/chezmoi ok upgrade-method replace-executable ok config-file ~/.config/chezmoi/chezmoi.toml, last modified 2022-09-23T13:48:30Z error source-dir ~/.local/share/chezmoi is a git working tree (error) ok suspicious-entries no suspicious entries error working-tree ~/.local/share/chezmoi is a git working tree (error) ok dest-dir ~ is a directory ok umask 002 ok cd-command found /bin/bash ok cd-args /bin/bash info diff-command not set warning edit-command vi not found in $PATH ok edit-args vi warning git-command git not found in $PATH warning merge-command vimdiff not found in $PATH ok shell-command found /bin/bash ok shell-args /bin/bash info age-command age not found in $PATH info gpg-command gpg not found in $PATH 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 ```

Additional context

Add any other context about the problem here.

twpayne commented 1 year ago

Thanks for spotting this! This bug was introduced in #2356.

jrmcdonald commented 1 year ago

No worries, only spotted it because my gitpod environments were getting set up with a newer version than local, and subsequently failing to apply the dotfiles.

Thanks for an awesome tool btw.