Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart add to an encrypted or template target hangs modify manager #176

Closed
dgudim opened this issue Nov 18, 2024 · 6 comments
Closed

Smart add to an encrypted or template target hangs modify manager #176

dgudim opened this issue Nov 18, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@dgudim
Copy link

dgudim commented Nov 18, 2024

Describe the bug

When using smart-add and the target in the chezmoi is either encrypted or a template, modify manager just hangs

To Reproduce

Steps to reproduce the behavior:

  1. chezmoi add --encrypt testfile
  2. chezmoi_modify_manager -s testfile
  3. ... nothing happens

Expected behavior

File is added as encrypted or a warning is printed

Actual behavior

Environment (please complete the following information):

  • chezmoi version v2.54.0
  • chezmoi_modify_manager version 3.5.0

Output of chezmoi_modify_manager --doctor

$ chezmoi_modify_manager --doctor

RESULT  CHECK             MESSAGE
Ok      version           3.5.0
Info    build             Other builder, identifies as: aur
Ok      rustc-version     1.81.0
Ok      host              os=linux, arch=x86_64, info=EndeavourOS Rolling Release (rolling) [64-bit]
Ok      has-chezmoi       Chezmoi found. Version: chezmoi version v2.54.0, commit 3825013d2967cdc3de141e602249f6c92a1a60d3-dirty, built at 2024-11-13T21:00:42Z
Ok      chezmoi-override  CHEZMOI_MODIFY_MANAGER_ASSUME_CHEZMOI_VERSION is not set
Ok      in-path           chezmoi_modify_manager is in PATH at /usr/bin/chezmoi_modify_manager
Ok      has-ignore        Ignore of **/*.src.ini found
Ok      no-hook-script    No legacy hook script found

Output of chezmoi doctor:
RESULT   CHECK                       MESSAGE
ok       version                     v2.54.0, commit 3825013d2967cdc3de141e602249f6c92a1a60d3-dirty, built at 2024-11-13T21:00:42Z
ok       latest-version              v2.54.0
ok       os-arch                     linux/amd64 (EndeavourOS)
ok       uname                       Linux black-bird 6.11.6-arch1-1.1 #1 SMP PREEMPT_DYNAMIC Sat, 02 Nov 2024 20:51:10 +0000 x86_64 GNU/Linux
ok       go-version                  go1.23.2 (gc)
ok       executable                  /usr/bin/chezmoi
ok       config-file                 ~/.config/chezmoi/chezmoi.toml, last modified 2024-11-18T20:51:07+02:00
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       umask                       022
ok       cd-command                  found /bin/bash
ok       cd-args                     /bin/bash
ok       diff-command                found /usr/bin/delta
ok       edit-command                found /usr/bin/nano
ok       edit-args                   /usr/bin/nano
ok       git-command                 found /usr/bin/git, version 2.47.0
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.4.6
info     pinentry-command            not set
info     1password-command           op not found in $PATH
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
ok       keepassxc-command           found /usr/bin/keepassxc-cli, version 2.7.9
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
@dgudim dgudim added the bug Something isn't working label Nov 18, 2024
@VorpalBlade
Copy link
Owner

Thanks for your report! I probably missed this since I have never used the encryption feature (I store my secrets in a password manager and fill in from that instead). I will have to look into how that works.

It may take a few days before I have time to dig into this though.

@VorpalBlade VorpalBlade self-assigned this Nov 18, 2024
@VorpalBlade
Copy link
Owner

Ah, I see what is happening. Chmm runs chezmoi add without the --encrypt flag. This makes chezmoi try to interactively ask a question on stdout:

chezmoi add ~/dummy
adding dummy would remove encrypted attribute, continue? yes/no/all/quit

But chmm swallows stdout (don't remember why that would have been done like that), so the output is never shown. In addition it appears chmm status output is also fully buffered rather than line buffered, so nothing is shown from that either. That also seems wrong.

@VorpalBlade
Copy link
Owner

A new release including the fix should be out later this evening.

@dgudim
Copy link
Author

dgudim commented Nov 20, 2024

Very nice! Thanks! I thought maybe smart add should encrypt the file if it's encrypted in the target (since it's smart 🤔 ) But this is also totally fine

@VorpalBlade
Copy link
Owner

VorpalBlade commented Nov 20, 2024

Very nice! Thanks! I thought maybe smart add should encrypt the file if it's encrypted in the target (since it's smart 🤔 ) But this is also totally fine

That is worth considering. Would have to look into how to determine which flags that need passing. And there is of course no way to do this for templates.

@dgudim
Copy link
Author

dgudim commented Nov 20, 2024

Templates, yeah, of course. For the encryption I just use the --encrypt flag.
https://www.chezmoi.io/user-guide/encryption/
So it looks like just checking for enctrypted_ prefix and adding the flag should work (?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants