Skip to content

Can't get chezmoi to follow a symlink to a folder #4780

@unikitty37

Description

@unikitty37

What exactly are you trying to do?

I am trying to copy sound files into ~/Library/Sounds on macOs and ~/.local/share/sounds on Linux, without having to list each file individually in a config file or have them in multiple places in chezmoi.

What have you tried so far?

In my chezmoi repo, I place the sounds in Library/Sounds. I symlink dot_local/share/sounds to point to ../../Library/Sounds, and verify from ls dot_local/share/sounds/ that the sound files can be reached.

$ ls -l Library/Sounds
total 5888
-rw-r--r-- 2 user staff   87414 Apr  2  2022 sound1.aiff
«snipped»

$ ls -l dot_local/share/sounds
lrwxr-xr-x 1 user staff 20 Nov 25 13:24 dot_local/share/sounds -> ../../Library/Sounds/

$ ls -l dot_local/share/sounds/
total 5888
-rw-r--r-- 2 user staff   87414 Apr  2  2022 sound1.aiff
«snipped»

In the repo root, I have a .chezmoiignore containing this:

{{- if (ne .chezmoi.os "darwin") }}
Library
{{- end }}

and in dot_local/share I have one containing this:

{{- if (eq .chezmoi.os "darwin") }}
sounds
{{- end }}

Chezmoi correctly updates the sound files on macOS, but does nothing on Linux. I would have expected that it would follow the symlink and copy the files that were in there, but what actually happens is this:

  • If the .local/share/sounds folder already exists, it is left unchanged
  • If the .local/share/sounds folder does not exist, it is created but left empty

The documentation link given at #1433 (reply in thread) seems to be based on a per-file template, rather than a per-folder one, meaning I would have to make 52 template files right now, plus more if I added any more sound files.

#2273 looks to be the solution, but not right now :)

Where else have you checked for solutions?

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

Unfortunately I ran chezmoi update without the flag, and now running it with the flag just produces "Already up to date."

This happens even though chezmoi has not copied the sound files to .local/share/sounds, so it should have something to do.

Output of chezmoi doctor

(run on the Arch Linux machine I'm trying to get the sounds onto)

$ chezmoi doctor
RESULT    CHECK                       MESSAGE
warning   version                     v2.67.0, built at 2025-11-03T16:38:40Z
ok        latest-version              v2.67.0
ok        os-arch                     linux/amd64 (Arch Linux)
ok        uname                       Linux zarch 6.17.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 14 Nov 2025 06:54:20 +0000 x86_64 GNU/Linux
ok        go-version                  go1.25.3 X:nodwarf5 (gc)
ok        executable                  /usr/bin/chezmoi
ok        config-file                 found ~/.config/chezmoi/chezmoi.yml, last modified 2025-11-03T15:42:59Z
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
error     hardlink                    failed creating hardlink from ~/.local/share/chezmoi to /tmp: link ~/.local/share/chezmoi/.chezmoi-doctor-hardlink-test /tmp/chezmoi-doctor4227479673/.chezmoi-doctor-hardlink-test: invalid cross-device link
ok        umask                       022
ok        cd-command                  found /usr/bin/zsh
ok        cd-args                     /usr/bin/zsh
info      diff-command                not set
ok        edit-command                found /usr/bin/vim
ok        edit-args                   /usr/bin/vim
ok        git-command                 found /usr/bin/git, version 2.52.0
ok        merge-command               found /usr/bin/vimdiff
ok        shell-command               found /usr/bin/zsh
ok        shell-args                  /usr/bin/zsh
info      age-command                 age not found in $PATH
ok        gpg-command                 found /usr/bin/gpg, version 2.4.8
info      pinentry-command            not set
ok        1password-command           found /usr/bin/op, version 2.32.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      secret-command              not set

Additional context

I really don't want to have to symlink each file individually, much less write a template per-file, because sooner or later a file will get added and not symlinked/templated, and then things will be out of sync.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions