twpayne / chezmoi

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

Setup on Windows 11 is broken #3063

Closed HolbyFPV closed 1 year ago

HolbyFPV commented 1 year ago

Describe the bug

I don't believe the setup is working correctly on my Windows 11 machine. I have tried the winget, chocolatey, and standalone releases and they all produce the same behavior.

To reproduce

Try to install this on Windows 11.

Expected behavior

The app Installs

Output of command with the --verbose flag

$ chezmoi init --debug
2023-06-23T21:52:17-04:00 INF persistentPreRunRootE args=["C:\\Users\\username\\bin\\chezmoi.exe","init","--debug"] goVersion=go1.20.5 version={"builtBy":"goreleaser","commit":"473189051ec4950baa342f19ae7a824f0c1ded1f","date":"2023-06-17T00:54:14Z","version":"2.34.2"}
2023-06-23T21:52:17-04:00 ERR Stat error="CreateFile C:/Users/username/.config/chezmoi/chezmoistate.boltdb: The system cannot find the path specified." component=system name=C:/Users/username/.config/chezmoi/chezmoistate.boltdb
2023-06-23T21:52:17-04:00 ERR Mkdir error="mkdir C:/Users/username/.local/share/chezmoi: Cannot create a file when that file already exists." component=system name=C:/Users/username/.local/share/chezmoi perm=511
2023-06-23T21:52:17-04:00 INF Stat component=system name=C:/Users/username/.local/share/chezmoi
2023-06-23T21:52:17-04:00 INF Stat component=system name=C:/Users/username/.local/share/chezmoi/.git
2023-06-23T21:52:17-04:00 ERR Mkdir error="mkdir C:/Users/username/.local/share/chezmoi: Cannot create a file when that file already exists." component=system name=C:/Users/username/.local/share/chezmoi perm=511
2023-06-23T21:52:17-04:00 INF Stat component=system name=C:/Users/username/.local/share/chezmoi
2023-06-23T21:52:17-04:00 ERR ReadFile error="open C:/Users/username/.local/share/chezmoi/.chezmoiroot: The system cannot find the file specified." component=system data= name=C:/Users/username/.local/share/chezmoi/.chezmoiroot size=0
2023-06-23T21:52:17-04:00 INF Stat component=system name=C:/Users/username/.local/share/chezmoi/.git
2023-06-23T21:52:17-04:00 ERR ReadFile error="open C:/Users/username/.local/share/chezmoi/.chezmoiversion: The system cannot find the file specified." component=system data= name=C:/Users/username/.local/share/chezmoi/.chezmoiversion size=0
2023-06-23T21:52:17-04:00 ERR ReadFile error="open C:/Users/username/.local/share/chezmoi/.chezmoiroot: The system cannot find the file specified." component=system data= name=C:/Users/username/.local/share/chezmoi/.chezmoiroot size=0
2023-06-23T21:52:17-04:00 INF ReadDir component=system name=C:/Users/username/.local/share/chezmoi
2023-06-23T21:52:17-04:00 INF ReadFile component=system data="{{ $email := promptString \"email\" }}\r\n[data]\r\n\temail = \"{{ $emai..." name=C:/Users/username/.local/share/chezmoi/.chezmoi.toml.tmpl size=115
email? string

Output of chezmoi doctor

```console PS C:\WINDOWS\system32> chezmoi doctor RESULT CHECK MESSAGE ok version v2.34.2, commit 473189051ec4950baa342f19ae7a824f0c1ded1f, built at 2023-06-17T00:54:14Z, built by goreleaser ok latest-version v2.34.2 ok os-arch windows/amd64 ok systeminfo Microsoft Windows 11 Education (10.0.22621 N/A Build 22621) ok go-version go1.20.5 (gc) ok executable ~/AppData/Local/Microsoft/WinGet/Links/chezmoi.exe ok upgrade-method replace-executable ok config-file no config file found ok source-dir ~/.local/share/chezmoi is a git working tree (clean) ok suspicious-entries no suspicious entries ok working-tree ~/.local/share/chezmoi is a git working tree (clean) ok dest-dir ~ is a directory ok cd-command found C:/WINDOWS/system32/cmd.exe ok cd-args 'C:\\WINDOWS\\system32\\cmd.exe' info diff-command not set ok edit-command found C:/Windows/system32/notepad.exe ok edit-args 'C:\\Windows\\system32\\notepad.exe' ok git-command found C:/Program Files/Git/cmd/git.exe, version 2.27.0 warning merge-command vimdiff not found in $PATH ok shell-command found C:/WINDOWS/system32/cmd.exe ok shell-args 'C:\\WINDOWS\\system32\\cmd.exe' 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 dashlane-command dcli 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 rbw-command rbw not found in $PATH info vault-command vault not found in $PATH info secret-command not set ```

Additional context

My .config folder is empty. I'm guessing the install process should have placed some files in there?

bradenhilton commented 1 year ago

When you say setup, are you referring to installation of chezmoi, or installation of dotfiles?

What happens when you provide input to the prompt in your output example?

What are the contents of .chezmoi.toml.tmpl?

HolbyFPV commented 1 year ago

When you say setup, are you referring to installation of chezmoi, or installation of dotfiles?

What happens when you provide input to the prompt in your output example?

What are the contents of .chezmoi.toml.tmpl?

I'm not really sure, I've never used this before and so far I'm suspecting that chezmoi itself isn't installed correctly.

I have ran winget install twpayne.chezmoi and it was successful. So I tried to start a repo to start syncing my dotfiles, the docs say run chezmoi init and that's where I start running into problems. I have pasted the logs from that above.

My use case is I have a bunch of dotfiles that I tried manually syncing between differing PCs through a repo/symlinks, but ran into the need for templating, which led me to this. However, I can't get it to work at all.

As far as I can tell, .chezmoi.toml.tmpl does not exist for me.

bradenhilton commented 1 year ago

When you run chezmoi init, chezmoi executes its config template if present (among other things). The output you provided shows that chezmoi is executing its config template (C:/Users/username/.local/share/chezmoi/.chezmoi.toml.tmpl). The template contains a prompt for an email address, which is what can be seen on the last line.

HolbyFPV commented 1 year ago

When you run chezmoi init, chezmoi executes its config template if present (among other things). The output you provided shows that chezmoi is executing its config template (C:/Users/username/.local/share/chezmoi/.chezmoi.toml.tmpl). The template contains a prompt for an email address, which is what can be seen on the last line.

[data]
    email = "{{ $email }}"
[genericSecret]
    command = "secret-rot13"

This is the contents of my file. I filled in my email address and I still get the same error.

HolbyFPV commented 1 year ago

When trying to add my first file, this is what I get

$ chezmoi add /d/Code/.dotfiles/Vivaldi/Preferences --debug
2023-06-23T23:38:05-04:00 INF persistentPreRunRootE args=["C:\\Users\\username\\bin\\chezmoi.exe","add","D:/Code/.dotfiles/Vivaldi/Preferences","--debug"] goVersion=go1.20.5 version={"builtBy":"goreleaser","commit":"473189051ec4950baa342f19ae7a824f0c1ded1f","date":"2023-06-17T00:54:14Z","version":"2.34.2"}
2023-06-23T23:38:05-04:00 INF Stat component=system name=C:/Users/username/.config/chezmoi/chezmoistate.boltdb
2023-06-23T23:38:05-04:00 ERR Mkdir error="mkdir C:/Users/username/.local/share/chezmoi: Cannot create a file when that file already exists." component=system name=C:/Users/username/.local/share/chezmoi perm=511
2023-06-23T23:38:05-04:00 INF Stat component=system name=C:/Users/username/.local/share/chezmoi
2023-06-23T23:38:05-04:00 INF Stat component=system name=C:/Users/username/.local/share/chezmoi/.git
2023-06-23T23:38:05-04:00 ERR Mkdir error="mkdir C:/Users/username/.local/share/chezmoi: Cannot create a file when that file already exists." component=system name=C:/Users/username/.local/share/chezmoi perm=511
2023-06-23T23:38:05-04:00 INF Stat component=system name=C:/Users/username/.local/share/chezmoi
2023-06-23T23:38:05-04:00 ERR ReadFile error="open C:/Users/username/.local/share/chezmoi/.chezmoiroot: The system cannot find the file specified." component=system data= name=C:/Users/username/.local/share/chezmoi/.chezmoiroot size=0
2023-06-23T23:38:05-04:00 ERR ReadFile error="open C:/Users/username/.local/share/chezmoi/.chezmoiversion: The system cannot find the file specified." component=system data= name=C:/Users/username/.local/share/chezmoi/.chezmoiversion size=0
2023-06-23T23:38:05-04:00 INF Stat component=system name=C:/Users/username/.local/share/chezmoi
2023-06-23T23:38:05-04:00 INF Stat component=system name=C:/Users/username/.local/share/chezmoi
2023-06-23T23:38:05-04:00 INF ReadDir component=system name=C:/Users/username/.local/share/chezmoi
chezmoi: D:/Code/.dotfiles/Vivaldi/Preferences: not in destination directory (C:/Users/username)
HolbyFPV commented 1 year ago

Ok, so I'm noticing I can add files from only my home directory. The dotfiles I want to add exist in other directories though, only a few of my programs use the true home directory. Does chezmoi support this kind of a use case?

bradenhilton commented 1 year ago

Can I use chezmoi to manage files outside my home directory?

HolbyFPV commented 1 year ago

Can I use chezmoi to manage files outside my home directory?

Ahh, I must have missed that. Having some trouble getting that method to work. Is there an example somewhere on github that I can reference?

twpayne commented 1 year ago

https://github.com/felipecrs/dotfiles and https://github.com/nandalopes/dotfiles both use this technique.

HolbyFPV commented 1 year ago

Appreciate the reference. I don't think this will be a good fit for me on Windows with how many apps utilize AppData over the home directory. Thanks for your time @twpayne @bradenhilton

bradenhilton commented 1 year ago

@notblam AppData is inside the home directory.