chezmoi edit <target file>
hardlink functionality breaks across btrfs subvolumes
#3846
Labels
enhancement
New feature or request
Describe the bug
Edit: I realise this is probably moreso a feature request rather than a bug.
When used on a btrfs filesystem, chezmoi does not attempt to detect or workaround btrfs subvolumes. Using
chezmoi edit <target file>
on a target dotfile (e.g.${XDG_CONFIG_HOME}/zsh/.zshrc
) opens the linked, renamed source file (e.g.${XDG_DATA_HOME}/chezmoi/dot_config/zsh/dot_zshrc
), rather than a hardlinked file with a matching extension to the target. This prevents syntax highlighting in this use case.The cause of this appears to be that chezmoi creates these hardlinks in
/tmp
, seemingly without a way to override this. If unaware, btrfs subvolumes are essentially folders with a few special properties. Without getting too into the deets here, they're often used to demarcate backup boundaries (btrfs folk might get annoyed at me saying that as they're technically snapshots) and btrfs does not permit cross-subvolume hardlinks./home/<user>
and/
are frequently on different subvolumes due to differentbackupsnapshot needs. Cache dirs are often on different subvolumes also to block them from other snapshots and, /tmp is...😆 Hang on a minute, isn't
/tmp
often in tmpfs, which would block hardlinks? I'm unsure of this.Would it be feasible to allow
tmpDir
to be set as a config variable in the same way asscriptTmpDir
, falling back to what's provided byTmpDir()
if unset/invalid? I've had a look through the source but much of it is over my head.To reproduce
chezmoi edit ~/.config/zsh/.zshrc
.local/share/chezmoi/dot_config/zsh/dot_zshrc
Expected behavior
As per the docs, chezmoi opens a hardlinked
.zshrc
file in a temp dir within the source directory.Output of command with the
--verbose
flag--verbose
returned no extra output alongside openingnvim
, so ran with--debug
instead, which produced the below on editor exit:Output of
chezmoi doctor
Additional context
Chezmoi is awesome, and I appreciate all the devs who've worked on it.
The text was updated successfully, but these errors were encountered: