twpayne/chezmoi

chezmoi in GitHub codespaces 1/2 works

rayjlinden opened this issue · 3 comments

What exactly are you trying to do?

I followed instructions and have my dotfile loading in my Codespace. They load perfectly - love it.

However, if I do chezmoi cd - I get an empty directory. (In fact, it is not a git directory.)

I would expect this to be the git dir for my dotfiles. Why isn't it?

What have you tried so far?

Here are the logs from the Codespace creation related to dot files:

2024-08-02 05:23:08.221Z: Installing dotfiles...
2024-08-02 05:23:08.236Z: $ devcontainer up --id-label Type=codespaces --workspace-folder /var/lib/docker/codespacemount/workspace/extraction-makeworld --expect-existing-container --skip-post-attach --mount type=bind,source=/.codespaces/agent/mount/cache,target=/vscode --container-data-folder .vscode-remote/data/Machine --container-system-data-folder /var/vscode-remote --log-level trace --log-format json --update-remote-user-uid-default never --mount-workspace-git-root false --config "/var/lib/docker/codespacemount/workspace/extraction-makeworld/.devcontainer/devcontainer.json" --override-config /root/.codespaces/shared/merged_devcontainer.json --dotfiles-repository https://github.com/rayjlinden/dotfiles --dotfiles-target-path /workspaces/.codespaces/.persistedshare/dotfiles --default-user-env-probe loginInteractiveShell --container-session-data-folder /workspaces/.codespaces/.persistedshare/devcontainers-cli/cache --secrets-file /root/.codespaces/shared/user-secrets-envs.json
2024-08-02 05:23:08.463Z: @devcontainers/cli 0.56.1. Node.js v18.20.3. linux 6.5.0-1022-azure x64.
2024-08-02 05:23:08.690Z: $ # Clone & install dotfiles
2024-08-02 05:23:08.694Z: Cloning into '/workspaces/.codespaces/.persistedshare/dotfiles'...

2024-08-02 05:23:09.802Z: Setting current directory to /workspaces/.codespaces/.persistedshare/dotfiles
Executing command /workspaces/.codespaces/.persistedshare/dotfiles/install.sh...

2024-08-02 05:23:09.803Z: Installing chezmoi to '/home/codespace/.local/bin/chezmoi'

2024-08-02 05:23:10.778Z: info found version 2.51.0 for latest/linux/amd64

2024-08-02 05:23:12.270Z: info installed /home/codespace/.local/bin/chezmoi

2024-08-02 05:23:12.288Z: Running 'chezmoi init --apply --source=/workspaces/.codespaces/.persistedshare/dotfiles'

Where else have you checked for solutions?

Output of any commands you've tried with --verbose flag

$ chezmoi --verbose $COMMAND

Output of chezmoi doctor

$ chezmoi doctor
RESULT   CHECK                       MESSAGE
ok       version                     v2.51.0, commit 2a7845f4ffe2fd427c140711c0d7d46424747363, built at 2024-07-15T20:05:05Z, built by goreleaser
ok       latest-version              v2.51.0
ok       os-arch                     linux/amd64 (Ubuntu 20.04.6 LTS (Focal Fossa))
ok       uname                       Linux codespaces-6a95ff 6.5.0-1022-azure #23~22.04.1-Ubuntu SMP Thu May  9 17:59:24 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
ok       go-version                  go1.22.5 (gc)
ok       executable                  ~/.local/bin/chezmoi
ok       upgrade-method              replace-executable
ok       config-file                 ~/.config/chezmoi/chezmoi.toml, last modified 2024-08-02T05:23:12Z
ok       source-dir                  ~/.local/share/chezmoi is a directory
ok       suspicious-entries          no suspicious entries
ok       working-tree                ~/.local/share/chezmoi is a directory
ok       dest-dir                    ~ is a directory
ok       umask                       022
ok       cd-command                  found /bin/bash
ok       cd-args                     /bin/bash
info     diff-command                not set
ok       edit-command                found /usr/bin/vi
ok       edit-args                   /usr/bin/vi
ok       git-command                 found /usr/local/bin/git, version 2.45.2
ok       merge-command               found /usr/bin/vimdiff
ok       shell-command               found /bin/bash
ok       shell-args                  /bin/bash
info     age-command                 age not found in $PATH
ok       gpg-command                 found /usr/bin/gpg, version 2.2.19
info     pinentry-command            not set
ok       1password-command           found /usr/local/bin/op, version 2.29.0
info     bitwarden-command           bw not found in $PATH
info     bitwarden-secrets-command   bws not found in $PATH
info     dashlane-command            dcli not found in $PATH
info     doppler-command             doppler 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     vlt-command                 vlt not found in $PATH
info     secret-command              not set

Additional context

Add any other context about the problem here.

Oh - finally found it:

{{- $codespaces:= env "CODESPACES" | not | not -}}
sourceDir = {{ .chezmoi.sourceDir | quote }}

The docs that show this could be a little more clear. I thought the section was optional if I wanted to do custom stuff for Codespaces. But the part above is required for it to even work.

#3890 makes this clear in the documentation.

Thanks!