twpayne / chezmoi

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

Subdirectories not supported in .chezmoitemplates #594

Closed remi-gelinas closed 4 years ago

remi-gelinas commented 4 years ago

Describe the bug

I'm trying to organize related templates into subdirectories in .chezmoitemplates, but it's looking like that breaks the discovery path.

To reproduce

  1. Create a tests directory in .chezmoitemplates
  2. Create a test_template file in .chezmoitemplates/tests
  3. Try and apply {{ template "tests/test_template" }} in a source template somewhere.

Expected behavior

chezmoi finds the correct template file.

Output of command with --verbose

$ chezmoi diff --verbose
chezmoi: template: /Users/bleh/dotfiles/src/testapply.tmpl:1:12: executing "/Users/bleh/dotfiles/src/testapply.tmpl" at <{{template "tests/test_template"}}>: template "tests/test_template" not defined
$ chezmoi doctor
     ok: version 1.7.12, commit bed22fcb91787c0d3d2d8ca61ebfe7799380f961, built at 2020-01-24T02:32:12Z
     ok: runtime.GOOS darwin, runtime.GOARCH amd64
     ok: /Users/bleh/dotfiles/src (source directory, perm 700)
     ok: /Users/bleh (destination directory, perm 755)
     ok: /Users/bleh/.config/chezmoi/chezmoi.toml (configuration file)
     ok: /bin/zsh (shell)
     ok: /usr/local/bin/nvim (editor)
     ok: /usr/bin/vimdiff (merge command)
     ok: /usr/local/bin/git (source VCS command, version 2.25.0)
     ok: /usr/local/bin/gpg (GnuPG, version 2.2.19)
warning: op (1Password CLI, not found)
     ok: /usr/local/bin/bw (Bitwarden CLI, version 1.8.0)
warning: gopass (gopass CLI, not found)
warning: keepassxc-cli (KeePassXC CLI, not found)
warning: lpass (LastPass CLI, not found)
warning: pass (pass CLI, not found)
warning: vault (Vault CLI, not found)
twpayne commented 4 years ago

Thanks for the report. Originally chezmoi used just the basename of the file as the template name, but I can't see a reason not to use the full relative path. #595 implements this.