with-editor icon indicating copy to clipboard operation
with-editor copied to clipboard

unexpected EOF while looking for matching `'' trying to edit agenix secret with `agenix -e`

Open ParetoOptimalDev opened this issue 3 years ago • 1 comments

I tried editing an agenix secret from M-x shell. I noticed the Successfully exported EDITOR message from with-editor. Then I tried editing my secret and this happened:

 agenix -e bws1.age
"\nWITH-EDITOR:: -c: line 1: unexpected EOF while looking for matching `''
"\nWITH-EDITOR:: -c: line 2: syntax error: unexpected end of file
bws1.age wasn't changed, skipping re-encryption.

I saw related issues such as #40 but wasn't sure how to use them to further debug this error.

No backtrace is available since there was no elisp error.

Here are my debug details:

with-editor: /nix/store/30wn4qms39hypf35r3bjaz1frccw906m-emacs-with-editor-20220506.420/share/emacs/site-lisp/elpa/with-editor-20220506.420/with-editor.el
emacs: /nix/store/k4lvc45h5adkg022jsgrdil2wckzn16a-emacs-28.1/bin/emacs (28.1)
system:
  system-type: gnu/linux
  system-configuration: x86_64-pc-linux-gnu
  system-configuration-options: --prefix=/nix/store/k4lvc45h5adkg022jsgrdil2wckzn16a-emacs-28.1 --disable-build-details --with-modules --with-x-toolkit=gtk3 --with-xft --with-cairo
server:
  server-running-p: t
  server-process: #<process server>
  server-use-tcp: nil
  server-name: server
  server-socket-dir: /run/user/1000/emacs
    server
  server-auth-dir: ~/.emacs.d/server/
    WARNING: not an accessible directory
with-editor-emacsclient-executable:
 value:   /nix/store/k4lvc45h5adkg022jsgrdil2wckzn16a-emacs-28.1/bin/emacsclient (28.1)
 default: /nix/store/k4lvc45h5adkg022jsgrdil2wckzn16a-emacs-28.1/bin/emacsclient (28.1)
 funcall: /nix/store/k4lvc45h5adkg022jsgrdil2wckzn16a-emacs-28.1/bin/emacsclient (28.1)
path:
  $PATH: "/run/wrappers/bin:/home/ParetoOptimalDev/.nix-profile/bin:/etc/profiles/per-user/ParetoOptimalDev/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin"
  exec-path: (/nix/store/4y41ixx1460mxcrl11r7iz5fqjc4zl1h-emacs-packages-deps/bin /run/wrappers/bin /home/ParetoOptimalDev/.nix-profile/bin /etc/profiles/per-user/ParetoOptimalDev/bin /nix/var/nix/profiles/default/bin /run/current-system/sw/bin /nix/store/k4lvc45h5adkg022jsgrdil2wckzn16a-emacs-28.1/libexec/emacs/28.1/x86_64-pc-linux-gnu)
  with-editor-emacsclient-path:
    /nix/store/k4lvc45h5adkg022jsgrdil2wckzn16a-emacs-28.1/bin (t)
      /nix/store/k4lvc45h5adkg022jsgrdil2wckzn16a-emacs-28.1/bin/.emacsclient-wrapped (28.1)
      /nix/store/k4lvc45h5adkg022jsgrdil2wckzn16a-emacs-28.1/bin/emacsclient (28.1)
    /nix/store/4y41ixx1460mxcrl11r7iz5fqjc4zl1h-emacs-packages-deps/bin (t)
      /nix/store/4y41ixx1460mxcrl11r7iz5fqjc4zl1h-emacs-packages-deps/bin/.emacsclient-wrapped (28.1)
      /nix/store/4y41ixx1460mxcrl11r7iz5fqjc4zl1h-emacs-packages-deps/bin/emacsclient (28.1)
    /run/wrappers/bin (/run/wrappers/wrappers.tJkUaEkMhV)
    /home/ParetoOptimalDev/.nix-profile/bin (/nix/store/k9hdnkka3rlhj4mqk122swlgyhzpr83x-home-manager-path/bin)
      /home/ParetoOptimalDev/.nix-profile/bin/emacsclient (28.1)
    /etc/profiles/per-user/ParetoOptimalDev/bin (nil)
    /nix/var/nix/profiles/default/bin (t)
    /run/current-system/sw/bin (t)
    /nix/store/k4lvc45h5adkg022jsgrdil2wckzn16a-emacs-28.1/libexec/emacs/28.1/x86_64-pc-linux-gnu (t)

ParetoOptimalDev avatar Jun 07 '22 23:06 ParetoOptimalDev

#40 is relevant indeed.

I believe that with-editor isn't the cause here but that various tools that use $EDITOR fail if they encounter quotes in the value of that variable. systemctl seems to be another.

And we just learned that agenix is yet another.

Check the value of with-editor-shell-command-use-emacsclient. The default is t but it seems, its nil for you. You have to set it to t to work around this.

tarsius avatar Jun 08 '22 10:06 tarsius