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

Stuck at "Contacting host: oauth2.googleapis.com:443" #238

Closed
benthamite opened this issue May 1, 2023 · 18 comments
Closed

Stuck at "Contacting host: oauth2.googleapis.com:443" #238

benthamite opened this issue May 1, 2023 · 18 comments

Comments

@benthamite
Copy link

benthamite commented May 1, 2023

The package was working fine until this morning, when I had to reinstall Emacs. Now it's stuck at "Contacting host: oauth2.googleapis.com:443" after I close the external browser and return to Emacs following the initial fetch ( "Authentication token successfully obtained by Emacs!").

Running pkill -USR2 Emacs from the terminal triggers a backtrace that shows the last command was epg-wait-for-status. Since I'm using Emacs 30, perhaps something changed in the epg feature since my last reinstall that is now causing this issue?

@heyestom
Copy link

heyestom commented May 2, 2023

Maybe the same issue as I just re-installed emacs albeit V28 on OSX. After going giving the google cloud application permissions Emacs just hangs with Decrypting /Users/myuser/oauth2-auto.plist...done

Looking at the messages buffer I see:

Log in to your account for Emacs in your browser window
Contacting host: oauth2.googleapis.com:443
Decrypting /Users/myuser/.emacs.d/oauth2-auto.plist...done

I can quit in which case I need to org-gcal--sync-unlock to try again but I get the same behaviour.

@benthamite
Copy link
Author

Yes, it seems to be the same issue. How did you install Emacs 28 on a Mac? emacs-plus@28 didn't work when I tried it yesterday.

@heyestom
Copy link

heyestom commented May 2, 2023

I used emacs-plus via homebrew:
Essentially:

brew tap d12frosted/emacs-plus

brew tap d12frosted/emacs-plus
brew install emacs-plus --with-no-titlebar-and-round-corners --with-native-comp
# use a brew service will get emacs to start at launch
brew services start d12frosted/emacs-plus/emacs-plus@28

I actually blogged what I did mostly to help myself next time :)

@benthamite
Copy link
Author

benthamite commented May 4, 2023

When Emacs hangs, can you run this on the terminal pkill -USR2 Emacs? Emacs should then generate a backtrace. Can you check that it matches the following (minus the redacted parts)? This is my own backtrace, and if we are both experiencing the same issue, the two should match.

Debugger entered--entering a function:
* substitute-command-keys("Quit")
epg-wait-for-status(#s(epg-context :protocol OpenPGP :program "/opt/homebrew/bin/gpg" :home-directory nil :armor t :textmode nil :include-certs nil :cipher-algorithm nil :digest-algorithm nil :compress-algorithm nil :passphrase-callback (plstore-passphrase-callback-function . [#<buffer  plstore /Users/pablostafforini/.config/emacs-profiles/4/oauth2-auto.plist> (("%28%22pablo.stafforini%40gmail.com%22%20org-gcal%29%0A" :secret-access-token t :secret-refresh-token t :secret-expiration t)) nil (("%28%22pablo.stafforini%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted]" :expiration 1683223878)) (("%28%22pablo.stafforini%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted]" :expiration 1683223878))]) :progress-callback nil :edit-callback nil :signers nil :sender nil :sig-notations nil :process #<process epg> :output-file "/var/folders/n6/67613fgn44zbwm4x_y9mgr4m0000gn/T/epg-output6fqHjt" :result nil :operation encrypt :pinentry-mode loopback :error-output "" :error-buffer #<buffer  *epg-error*>) ("BEGIN_ENCRYPTION"))
epg-start-encrypt(#s(epg-context :protocol OpenPGP :program "/opt/homebrew/bin/gpg" :home-directory nil :armor t :textmode nil :include-certs nil :cipher-algorithm nil :digest-algorithm nil :compress-algorithm nil :passphrase-callback (plstore-passphrase-callback-function . [#<buffer  plstore /Users/pablostafforini/.config/emacs-profiles/4/oauth2-auto.plist> (("%28%22pablo.stafforini%40gmail.com%22%20org-gcal%29%0A" :secret-access-token t :secret-refresh-token t :secret-expiration t)) nil (("%28%22pablo.stafforini%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted]" :expiration 1683223878)) (("%28%22pablo.stafforini%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted]" :expiration 1683223878))]) :progress-callback nil :edit-callback nil :signers nil :sender nil :sig-notations nil :process #<process epg> :output-file "/var/folders/n6/67613fgn44zbwm4x_y9mgr4m0000gn/T/epg-output6fqHjt" :result nil :operation encrypt :pinentry-mode loopback :error-output "" :error-buffer #<buffer  *epg-error*>) #s(epg-data :file nil :string "[redacted]") nil nil nil)
epg-encrypt-string(#s(epg-context :protocol OpenPGP :program "/opt/homebrew/bin/gpg" :home-directory nil :armor t :textmode nil :include-certs nil :cipher-algorithm nil :digest-algorithm nil :compress-algorithm nil :passphrase-callback (plstore-passphrase-callback-function . [#<buffer  plstore /Users/pablostafforini/.config/emacs-profiles/4/oauth2-auto.plist> (("%28%22pablo.stafforini%40gmail.com%22%20org-gcal%29%0A" :secret-access-token t :secret-refresh-token t :secret-expiration t)) nil (("%28%22pablo.stafforini%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted]" :expiration 1683223878)) (("%28%22pablo.stafforini%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted]" :expiration 1683223878))]) :progress-callback nil :edit-callback nil :signers nil :sender nil :sig-notations nil :process #<process epg> :output-file "/var/folders/n6/67613fgn44zbwm4x_y9mgr4m0000gn/T/epg-output6fqHjt" :result nil :operation encrypt :pinentry-mode loopback :error-output "" :error-buffer #<buffer  *epg-error*>) "[redacted]" nil)
plstore--insert-buffer([#<buffer  plstore /Users/pablostafforini/.config/emacs-profiles/4/oauth2-auto.plist> (("%28%22pablo.stafforini%40gmail.com%22%20org-gcal%29%0A" :secret-access-token t :secret-refresh-token t :secret-expiration t)) nil (("%28%22pablo.stafforini%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted]" :expiration 1683223878)) (("%28%22pablo.stafforini%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted]" :expiration 1683223878))])
plstore-save([#<buffer  plstore /Users/pablostafforini/.config/emacs-profiles/4/oauth2-auto.plist> (("%28%22pablo.stafforini%40gmail.com%22%20org-gcal%29%0A" :secret-access-token t :secret-refresh-token t :secret-expiration t)) nil (("%28%22pablo.stafforini%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted]" :expiration 1683223878)) (("%28%22pablo.stafforini%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted]" :expiration 1683223878))])
oauth2-auto--plstore-write("[redacted email]" org-gcal (:access-token "[redacted]" :expiration 1683223878))
#f(compiled-function () #<bytecode 0x4c7ba12e4af64d9>)()
#f(compiled-function (op value) #<bytecode 0x1b295ec9fb212f8>)(:next #f(compiled-function () #<bytecode 0x198000fa5c91>))
iter-next(#f(compiled-function (op value) #<bytecode 0x1b295ec9fb212f8>) #f(compiled-function () #<bytecode 0x198000fa5c91>))
aio--step(#f(compiled-function (op value) #<bytecode 0x1b295ec9fb212f8>) #s(aio-promise nil (#[257 "\302\301\300\3#\207" [#s(aio-promise nil nil) #[514 "\1\303\267\202.\0\302\300\242\240\210\301\304\240\207\301\1\240\210\304C\305\306\2\300\301\302%\216\3072(\0\302\242 \210\202!\0\1\310\240)\210\207\311\312\3\"\207" [(#[0 "\301\302\300\242\"\207" [(#0) signal iter-end-of-sequence] 3]) (#0) (#[0 "\301\302\242\240\210\303\300\242\240\207" [(#[0 "\304\3061\21\0\300\242 \305\301\242\240\2100\202\33\0\303\1\240\210\305\302\242\240\262\1\240\207" [(nil) (#[0 "\301\302\242\240\210\303\300\242\240\207" [(#[0 "\304\3061\23\0\307\300\242\310\"\305\301\242\240\2100\202\35\0\303\1\240\210\305\302\242\240\262\1\240\207" [(nil) (#[0 "\301\302\242\240\210\303\300\242\240\207" [(#[0 "\304\3061\22\0\307\310\300\"\305\303\242\240\2100\202\34\0\302\1\240\210\305\301\242\240\262\1\240\207" [(nil) (#[0 "\302\304\305\300\"\303\301\242\240\210\240\207" [(nil) (#[0 "\301\302\242\240\210\303\300\242\240\207" [(#[0 "\302\305\304\300\242\"\303\301\242\240\210\240\207" [(nil) (#[0 "\301\302\300\242\"\207" [(#0) signal iter-end-of-sequence] 3]) (#0) #6 #s(aio-promise nil nil) aio-resolve] 4]) (nil) (#0) #6] 2]) (#0) #6 make-closure #[0 "\301\300\242@\300\242A\"\207" [V0 signal] 3]] 4]) (nil) (#[0 "\301\302\242\240\210\303\300\242\240\207" [(#[0 "\302\305\304\300\242\"\303\301\242\240\210\240\207" [(nil) (#[0 "\301\302\300\242\"\207" [(#0) signal iter-end-of-sequence] 3]) (#0) #6 #s(aio-promise nil nil) aio-resolve] 4]) (nil) (#0) #6] 2]) (#0) #6 (error) make-closure #[0 "\300\242\207" [V0] 1]] 4]) (nil) (#0) #6] 2]) (#[0 "\302\304\305\300\"\303\301\242\240\210\240\207" [(nil) (#[0 "\301\302\242\240\210\303\300\242\240\207" [(#[0 "\302\305\304\300\242\"\303\301\242\240\210\240\207" [(nil) (#[0 "\301\302\300\242\"\207" [(#0) signal iter-end-of-sequence] 3]) (#0) #6 #s(aio-promise nil nil) aio-resolve] 4]) (nil) (#0) #6] 2]) (#0) #6 make-closure #[0 "\301\300\242@\300\242A\"\207" [V0 signal] 3]] 4]) (nil) (#0) #6 (error) plist-get :access-token] 4]) (nil) (#0) #6] 2]) (#[0 "\302\304\305\300\"\303\301\242\240\210\240\207" [(nil) (#[0 "\301\302\242\240\210\303\300\242\240\207" [(#[0 "\302\305\304\300\242\"\303\301\242\240\210\240\207" [(nil) (#[0 "\301\302\300\242\"\207" [(#0) signal iter-end-of-sequence] 3]) (#0) #6 #s(aio-promise nil nil) aio-resolve] 4]) (nil) (#0) #6] 2]) (#0) #6 make-closure #[0 "\301\300\242@\300\242A\"\207" [V0 signal] 3]] 4]) (nil) (#0) #6 (error)] 4]) (nil) (#0) #6] 2]) #s(hash-table size 2 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (:close 6 :next 15)) nil make-closure #[0 "\300\242?\205\16\0\303\301\242\240\210\302\304\240\207" [V0 V1 V2 V3 nil] 2] cps--yield t error "Unknown iterator operation %S"] 9 "\n\n(fn OP VALUE)"] aio--step] 5 "\n\n(fn VALUE)"])) #f(compiled-function () #<bytecode 0x198000fa5c91>))
#f(compiled-function (value) #<bytecode -0x17af7471005297d4>)(#f(compiled-function () #<bytecode 0x198000fa5c91>))
apply(#f(compiled-function (value) #<bytecode -0x17af7471005297d4>) #f(compiled-function () #<bytecode 0x198000fa5c91>))
timer-event-handler([t 25683 59191 436541 nil #f(compiled-function (value) #<bytecode -0x17af7471005297d4>) (#f(compiled-function () #<bytecode 0x198000fa5c91>)) nil 0 nil])
aio-wait-for(#s(aio-promise nil nil))
org-gcal--get-access-token("[redacted email]")
(format "Bearer %s" (org-gcal--get-access-token calendar-id))
(cons "Authorization" (format "Bearer %s" (org-gcal--get-access-token calendar-id)))
(list '("Accept" . "application/json") (cons "Authorization" (format "Bearer %s" (org-gcal--get-access-token calendar-id))))
(request-deferred (org-gcal-events-url calendar-id) :type "GET" :headers (list '("Accept" . "application/json") (cons "Authorization" (format "Bearer %s" (org-gcal--get-access-token calendar-id)))) :params (append (cons (cons "access_token" (org-gcal--get-access-token calendar-id)) '(("singleEvents" . "True"))) (if org-gcal-local-timezone (progn (list (cons "timeZone" org-gcal-local-timezone)))) (let* ((val (let* ((x (and t (alist-get calendar-id org-gcal--sync-tokens nil nil #'equal))) (s (and x (listp x)))) (if s x nil)))) (progn (ignore (seqp val)) (let* ((x17 (seq--elt-safe val 1)) (x18 (seq--elt-safe val 0))) (let ((sync-token x17) (expires x18)) (cond ((and expires sync-token (time-less-p (current-time) expires)) (list (cons "syncToken" sync-token))) (t (let* ((p (assoc calendar-id org-gcal--sync-tokens #'equal))) (progn (if p (setq org-gcal--sync-tokens (delq p org-gcal--sync-tokens))) nil)) (list (cons "timeMin" (org-gcal--format-time2iso up-time)) (cons "timeMax" (org-gcal--format-time2iso down-time))))))))) (if page-token (progn (list (cons "pageToken" page-token))))) :parser 'org-gcal--json-read)
org-gcal--sync-request-events("[redacted email]" nil (25682 38319 502901 0) (25693 8623 502907 0))
(setq it (org-gcal--sync-request-events calendar-id page-token up-time down-time))
(let (it) (setq it (org-gcal--sync-request-events calendar-id page-token up-time down-time)) (setq it (deferred:nextc it #'(lambda (response) (let ((retry-fn #'(lambda nil (org-gcal--sync-calendar-events calendar-id-file skip-export silent page-token up-time down-time parent-events)))) (org-gcal--sync-handle-response response calendar-id-file page-token-cons down-time retry-fn))))) (setq it (deferred:nextc it #'(lambda (events) (org-gcal--sync-handle-events calendar-id calendar-file events nil up-time down-time parent-events)))) (setq it (deferred:nextc it #'(lambda (entries) (org-gcal--sync-update-entries calendar-id entries skip-export)))) (setq it (deferred:nextc it #'(lambda (_) (let ((pt (car (last page-token-cons)))) (if pt (org-gcal--sync-calendar-events calendar-id-file skip-export silent pt up-time down-time parent-events) (deferred:succeed nil)))))) it)
(let* ((calendar-id (car calendar-id-file)) (calendar-file (cdr calendar-id-file)) (page-token-cons '(dummy))) (let (it) (setq it (org-gcal--sync-request-events calendar-id page-token up-time down-time)) (setq it (deferred:nextc it #'(lambda (response) (let ((retry-fn #'(lambda nil (org-gcal--sync-calendar-events calendar-id-file skip-export silent page-token up-time down-time parent-events)))) (org-gcal--sync-handle-response response calendar-id-file page-token-cons down-time retry-fn))))) (setq it (deferred:nextc it #'(lambda (events) (org-gcal--sync-handle-events calendar-id calendar-file events nil up-time down-time parent-events)))) (setq it (deferred:nextc it #'(lambda (entries) (org-gcal--sync-update-entries calendar-id entries skip-export)))) (setq it (deferred:nextc it #'(lambda (_) (let ((pt (car (last page-token-cons)))) (if pt (org-gcal--sync-calendar-events calendar-id-file skip-export silent pt up-time down-time parent-events) (deferred:succeed nil)))))) it))
org-gcal--sync-calendar-events(("[redacted email]" . "[redacted path]") t nil nil (25682 38319 502901 0) (25693 8623 502907 0) (dummy))
(setq it (org-gcal--sync-calendar-events calendar-id-file skip-export silent nil up-time down-time parent-events))
(let (it) (setq it (org-gcal--sync-calendar-events calendar-id-file skip-export silent nil up-time down-time parent-events)) (setq it (deferred:nextc it #'(lambda (_) (deferred:loop (cl-remove-duplicates (cdr parent-events) :test #'string=) #'(lambda (parent-event-id) (if (eq org-gcal-recurring-events-mode 'nested) (progn (let (it) (setq it (org-gcal--sync-event calendar-id-file parent-event-id skip-export)) (setq it (org-gcal--sync-instances calendar-id-file parent-event-id skip-export silent nil up-time down-time)) it)))))))) it)
(let* ((parent-events (list 'dummy))) (let (it) (setq it (org-gcal--sync-calendar-events calendar-id-file skip-export silent nil up-time down-time parent-events)) (setq it (deferred:nextc it #'(lambda (_) (deferred:loop (cl-remove-duplicates (cdr parent-events) :test #'string=) #'(lambda (parent-event-id) (if (eq org-gcal-recurring-events-mode 'nested) (progn (let (it) (setq it (org-gcal--sync-event calendar-id-file parent-event-id skip-export)) (setq it (org-gcal--sync-instances calendar-id-file parent-event-id skip-export silent nil up-time down-time)) it)))))))) it))
org-gcal--sync-calendar(("[redacted email]" . "[redacted path]") t nil (25682 38319 502901 0) (25693 8623 502907 0))
(setq it (org-gcal--sync-calendar calendar-id-file skip-export silent up-time down-time))
(let (it) (setq it (org-gcal--sync-calendar calendar-id-file skip-export silent up-time down-time)) (setq it (deferred:succeed nil)) (setq it (deferred:nextc it #'(lambda (_) (org-gcal--notify "Completed event fetching ." (concat "Events fetched into\n" (cdr calendar-id-file)) silent) (deferred:succeed nil)))) it)
(closure ((it . #s(deferred :callback (closure ((silent) (skip-export . t)) (_) (org-generic-id-update-id-locations org-gcal-entry-id-property) (if t (progn (mapc #'(lambda (file) (save-current-buffer (set-buffer (find-file-noselect file 'nowarn)) (save-excursion (save-restriction (widen) (org-gcal--sync-unlock) (org-gcal-sync-buffer skip-export silent 'filter-time 'filter-managed))))) (org-generic-id-files))))) :errorback deferred:default-errorback :cancel deferred:default-cancel :next #s(deferred :callback #f(compiled-function (x) #<bytecode 0x19d483eb805290ea>) :errorback #f(compiled-function (e) #<bytecode 0xbe9af93fb6ece4c>) :cancel deferred:default-cancel :next nil :status nil :value nil) :status nil :value nil)) (down-time 25693 8623 502907 0) (up-time 25682 38319 502901 0) (silent) (skip-export . t)) (calendar-id-file) (let (it) (setq it (org-gcal--sync-calendar calendar-id-file skip-export silent up-time down-time)) (setq it (deferred:succeed nil)) (setq it (deferred:nextc it #'(lambda (_) (org-gcal--notify "Completed event fetching ." (concat "Events fetched into\n" (cdr calendar-id-file)) silent) (deferred:succeed nil)))) it))(("[redacted email]" . "[redacted path]"))
deferred:call-lambda((closure ((it . #s(deferred :callback (closure ((silent) (skip-export . t)) (_) (org-generic-id-update-id-locations org-gcal-entry-id-property) (if t (progn (mapc #'(lambda (file) (save-current-buffer (set-buffer (find-file-noselect file 'nowarn)) (save-excursion (save-restriction (widen) (org-gcal--sync-unlock) (org-gcal-sync-buffer skip-export silent 'filter-time 'filter-managed))))) (org-generic-id-files))))) :errorback deferred:default-errorback :cancel deferred:default-cancel :next #s(deferred :callback #f(compiled-function (x) #<bytecode 0x19d483eb805290ea>) :errorback #f(compiled-function (e) #<bytecode 0xbe9af93fb6ece4c>) :cancel deferred:default-cancel :next nil :status nil :value nil) :status nil :value nil)) (down-time 25693 8623 502907 0) (up-time 25682 38319 502901 0) (silent) (skip-export . t)) (calendar-id-file) (let (it) (setq it (org-gcal--sync-calendar calendar-id-file skip-export silent up-time down-time)) (setq it (deferred:succeed nil)) (setq it (deferred:nextc it #'(lambda (_) (org-gcal--notify "Completed event fetching ." (concat "Events fetched into\n" (cdr calendar-id-file)) silent) (deferred:succeed nil)))) it)) ("[redacted email]" . "[redacted path]"))
#f(compiled-function (x) #<bytecode -0x10ebdc8f4730cd9e>)(nil)
deferred:call-lambda(#f(compiled-function (x) #<bytecode -0x10ebdc8f4730cd9e>) nil)
deferred:exec-task(#s(deferred :callback #f(compiled-function (x) #<bytecode -0x10ebdc8f4730cd9e>) :errorback deferred:default-errorback :cancel #f(compiled-function (x) #<bytecode 0x16c9e242161bc949>) :next #s(deferred :callback (closure ((silent) (skip-export . t)) (_) (org-generic-id-update-id-locations org-gcal-entry-id-property) (if t (progn (mapc #'(lambda (file) (save-current-buffer (set-buffer (find-file-noselect file 'nowarn)) (save-excursion (save-restriction (widen) (org-gcal--sync-unlock) (org-gcal-sync-buffer skip-export silent 'filter-time 'filter-managed))))) (org-generic-id-files))))) :errorback deferred:default-errorback :cancel deferred:default-cancel :next #s(deferred :callback #f(compiled-function (x) #<bytecode 0x19d483eb805290ea>) :errorback #f(compiled-function (e) #<bytecode 0xbe9af93fb6ece4c>) :cancel deferred:default-cancel :next nil :status nil :value nil) :status nil :value nil) :status nil :value nil) ok nil)
deferred:worker()
apply(deferred:worker nil)
timer-event-handler([t 25683 59183 530920 nil deferred:worker nil nil 0 nil])

@heyestom
Copy link

heyestom commented May 5, 2023

Debugger entered--entering a function:
* substitute-command-keys("Quit")
  epg-wait-for-status(#s(epg-context :protocol OpenPGP :program "/opt/homebrew/bin/gpg" :home-directory nil :armor t :textmode nil :include-certs nil :cipher-algorithm nil :digest-algorithm nil :compress-algorithm nil :passphrase-callback (plstore-passphrase-callback-function . [#<buffer  plstore /Users/tom.heyes/.emacs.d/oauth2-auto.plist> (("%28%22[redacted-email]%40gmail.com%22%20org-gcal%29%0A" :secret-access-token t :secret-refresh-token t :secret-expiration t)) nil (("%28%22[redacted-email]%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted-token]" :refresh-token "[refresh-token]" :expiration 1683280816)) (("%28%22[redacted-email]%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted-token]" :refresh-token "[refresh-token]" :expiration 1683280816))]) :progress-callback nil :edit-callback nil :signers nil :sender nil :sig-notations nil :process #<process epg> :output-file "/var/folders/vb/_8g2pzs94yn143r9_k22b0t00000gq/T/e..." :result nil :operation encrypt :pinentry-mode nil :error-output "" :error-buffer #<buffer  *epg-error*>) ("BEGIN_ENCRYPTION"))
  epg-start-encrypt(#s(epg-context :protocol OpenPGP :program "/opt/homebrew/bin/gpg" :home-directory nil :armor t :textmode nil :include-certs nil :cipher-algorithm nil :digest-algorithm nil :compress-algorithm nil :passphrase-callback (plstore-passphrase-callback-function . [#<buffer  plstore /Users/tom.heyes/.emacs.d/oauth2-auto.plist> (("%28%22[redacted-email]%40gmail.com%22%20org-gcal%29%0A" :secret-access-token t :secret-refresh-token t :secret-expiration t)) nil (("%28%22[redacted-email]%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted-token]" :refresh-token "[refresh-token]" :expiration 1683280816)) (("%28%22[redacted-email]%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted-token]" :refresh-token "[refresh-token]" :expiration 1683280816))]) :progress-callback nil :edit-callback nil :signers nil :sender nil :sig-notations nil :process #<process epg> :output-file "/var/folders/vb/_8g2pzs94yn143r9_k22b0t00000gq/T/e..." :result nil :operation encrypt :pinentry-mode nil :error-output "" :error-buffer #<buffer  *epg-error*>) #s(epg-data :file nil :string "((\"%28%22[redacted-email]%40gmail.com%22%20org-gcal%29%0A\"...") nil nil nil)
  epg-encrypt-string(#s(epg-context :protocol OpenPGP :program "/opt/homebrew/bin/gpg" :home-directory nil :armor t :textmode nil :include-certs nil :cipher-algorithm nil :digest-algorithm nil :compress-algorithm nil :passphrase-callback (plstore-passphrase-callback-function . [#<buffer  plstore /Users/tom.heyes/.emacs.d/oauth2-auto.plist> (("%28%22[redacted-email]%40gmail.com%22%20org-gcal%29%0A" :secret-access-token t :secret-refresh-token t :secret-expiration t)) nil (("%28%22[redacted-email]%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted-token]" :refresh-token "[refresh-token]" :expiration 1683280816)) (("%28%22[redacted-email]%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted-token]" :refresh-token "[refresh-token]" :expiration 1683280816))]) :progress-callback nil :edit-callback nil :signers nil :sender nil :sig-notations nil :process #<process epg> :output-file "/var/folders/vb/_8g2pzs94yn143r9_k22b0t00000gq/T/e..." :result nil :operation encrypt :pinentry-mode nil :error-output "" :error-buffer #<buffer  *epg-error*>) "((\"%28%22[redacted-email]%40gmail.com%22%20org-gcal%29%0A\"..." nil)
  plstore--insert-buffer([#<buffer  plstore /Users/tom.heyes/.emacs.d/oauth2-auto.plist> (("%28%22[redacted-email]%40gmail.com%22%20org-gcal%29%0A" :secret-access-token t :secret-refresh-token t :secret-expiration t)) nil (("%28%22[redacted-email]%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted-token]" :refresh-token "[refresh-token]" :expiration 1683280816)) (("%28%22[redacted-email]%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted-token]" :refresh-token "[refresh-token]" :expiration 1683280816))])
  plstore-save([#<buffer  plstore /Users/tom.heyes/.emacs.d/oauth2-auto.plist> (("%28%22[redacted-email]%40gmail.com%22%20org-gcal%29%0A" :secret-access-token t :secret-refresh-token t :secret-expiration t)) nil (("%28%22[redacted-email]%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted-token]" :refresh-token "[refresh-token]" :expiration 1683280816)) (("%28%22[redacted-email]%40gmail.com%22%20org-gcal%29%0A" :access-token "[redacted-token]" :refresh-token "[refresh-token]" :expiration 1683280816))])
  oauth2-auto--plstore-write("[redacted-email]" org-gcal (:access-token "[redacted-token]" :refresh-token "[refresh-token]" :expiration 1683280816))
  #f(compiled-function () #<bytecode 0xa44911ad56e12e5>)()
  #f(compiled-function (op value) #<bytecode -0x1d015462e52ffb01>)(:next #f(compiled-function () #<bytecode -0x197ae99b64ab3e97>))
  iter-next(#f(compiled-function (op value) #<bytecode -0x1d015462e52ffb01>) #f(compiled-function () #<bytecode -0x197ae99b64ab3e97>))
  aio--step(#f(compiled-function (op value) #<bytecode -0x1d015462e52ffb01>) #s(aio-promise nil (#[257 "\302\300\301\3#\207" [#[514 "\1\303\267\202/\0\300\302\242\240\210\301\304\240\207\301\1\240\210\304C\305\306\300\301\302\5%\216\3072)\0\300\242 \210\202!\0000\1\310\240\210)\207\311\312\3\"\207" [(#[0 "\302\301\242\240\210\300\303\242\240\207" [#6 ... ... ...] 2]) (#0) (#[0 "\301\302\300\242\"\207" [... signal iter-end-of-sequence] 3]) #s(hash-table size 2 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (:close 6 :next 15)) nil make-closure #[0 "\303\242?\205\16\0\300\302\242\240\210\301\304\240\207" [V0 V1 V2 V3 nil] 2] cps--yield t error "Unknown iterator operation %S"] 9 "\n\n(fn OP VALUE)"] #s(aio-promise nil nil) aio--step] 5 "\n\n(fn VALUE)"])) #f(compiled-function () #<bytecode -0x197ae99b64ab3e97>))
  #f(compiled-function (value) #<bytecode -0x121b1aaf86691752>)(#f(compiled-function () #<bytecode -0x197ae99b64ab3e97>))
  apply(#f(compiled-function (value) #<bytecode -0x121b1aaf86691752>) #f(compiled-function () #<bytecode -0x197ae99b64ab3e97>))
  timer-event-handler([t 25684 50593 464181 nil #f(compiled-function (value) #<bytecode -0x121b1aaf86691752>) (#f(compiled-function () #<bytecode -0x197ae99b64ab3e97>)) nil 0 nil])
  aio-wait-for(#s(aio-promise nil nil))
  org-gcal--get-access-token("[redacted-email]")
  org-gcal--sync-request-events("[redacted-email]" nil (25645 14479 195541 0) (25763 57231 195542 0))
  org-gcal--sync-calendar-events(("[redacted-email]" . "[redacted-path]") nil nil nil (25645 14479 195541 0) (25763 57231 195542 0) (dummy))
  org-gcal--sync-calendar(("[redacted-email]" . "[redacted-path]") nil nil (25645 14479 195541 0) (25763 57231 195542 0))
  #f(compiled-function (calendar-id-file) #<bytecode -0x11f647efdce93eb4>)(("[redacted-email]" . "[redacted-path]"))
  deferred:call-lambda(#f(compiled-function (calendar-id-file) #<bytecode -0x11f647efdce93eb4>) ("[redacted-email]" . "[redacted-path]"))
  #f(compiled-function (x) #<bytecode 0x1d9d1a1d5c16cc38>)(nil)
  deferred:call-lambda(#f(compiled-function (x) #<bytecode 0x1d9d1a1d5c16cc38>) nil)
  deferred:exec-task(#s(deferred :callback #f(compiled-function (x) #<bytecode 0x1d9d1a1d5c16cc38>) :errorback deferred:default-errorback :cancel #f(compiled-function (x) #<bytecode -0x16ab03275505983>) :next #s(deferred :callback #f(compiled-function (_) #<bytecode 0x1b5de04ef2ea6d32>) :errorback deferred:default-errorback :cancel deferred:default-cancel :next #s(deferred :callback #f(compiled-function (x) #<bytecode 0x19d481b547efdfea>) :errorback #f(compiled-function (e) #<bytecode 0xa05d863210d7ec5>) :cancel deferred:default-cancel :next nil :status nil :value nil) :status nil :value nil) :status nil :value nil) ok nil)
  deferred:worker()
  apply(deferred:worker nil)
  timer-event-handler([t 25684 50575 198755 nil deferred:worker nil nil 0 nil])

@benthamite
Copy link
Author

Thanks. I'm a Elisp newbie but it looks like we both have the same issue. But I'm not sure what could be causing it given that (1) you are using a stable Emacs version and (2) org-gcal hasn't been updated recently. Did you also update your brew packages? Perhaps a library changed?

@heyestom
Copy link

heyestom commented May 9, 2023

Hey, sorry for being slow, I'm traveling at the moment without my Mac book. I had a similar train of thought about brew package given that no obvious emacs dependacy had changed...

I'll take a look when I get back 🙂

@bcollison
Copy link

I experienced the same issue, and noticed that I had updated my gnupg package via homebrew (to 2.4.1) before the issue started. I downgraded to 2.4.0 and the issue went away. I haven't investigated if gnupg is not being used properly, or if 2.4.1 has a bug...
GNU Emacs 28.2 (build 2, x86_64-apple-darwin21.6.0, NS appkit-2113.60 Version 12.6.5 (Build 21G531)) of 2023-04-26 (via emacplus)

working gnupg:
gpg (GnuPG) 2.4.0 libgcrypt 1.10.2

non-working gnupg:
gpg (GnuPG) 2.4.1 libgcrypt 1.10.2

@bcollison
Copy link

I think this is the underlying issue: https://dev.gnupg.org/T6481

@benthamite
Copy link
Author

Thanks. This solved the problem.

To downgrade to 2.4.0:

brew uninstall --ignore-dependencies gnupg
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/59edfe598541186430d49cc34f42671e849e2fc9/Formula/gnupg.rb
HOHOMEBREW_NO_INSTALL_CLEANUP=TRUE brew install -s gnupg.rb
brew pin gnupg

@heyestom you may want to try this solution.

@heyestom
Copy link

Thanks @benthamite and @bcollison. Downgrading gnupg to 2.4.0 also fixed it for me. :)

@bitozoid
Copy link

FTR, I found this on reddit and it worked for me. No need to downgrade.

(fset 'epg-wait-for-status 'ignore)

https://www.reddit.com/r/emacs/comments/137r7j7/gnupg_241_encryption_issues_with_emacs_orgmode/

@bitozoid
Copy link

Maybe it is not a good idea. I have found other issues with epg.

@benthamite
Copy link
Author

benthamite commented Sep 12, 2023

Note that I recently reinstalled Emacs and downgrading resulted in (epg-error "Decryption failed" ""). What solved it for me was following some of @aliyss's suggestions in this comment. Here's exactly what I did:

  1. Downgrade to 2.4.0, using this script (more reliable than the manual method I describe above).

  2. Add this to your init file:

    (require 'epa-file)
    (setq epg-pinentry-mode 'loopback)
    (epa-file-enable)
    (setq epg-gpg-program "/opt/homebrew/bin/gpg") ; replace with actual path to gpg if different
    (setq plstore-cache-passphrase-for-symmetric-encryption t)
  1. Restart Emacs.

[Edit: after trying to downgrade with this script, I experienced some issues that went away when I (re)installed gpg2 (brew install gpg2). I’m not sure exactly what happened, but the method in my previous comment might be preferable after all.]

@thomaslaich
Copy link

FTR, I found this on reddit and it worked for me. No need to downgrade.

(fset 'epg-wait-for-status 'ignore)

reddit.com/r/emacs/comments/137r7j7/gnupg_241_encryption_issues_with_emacs_orgmode

Solved it for me! Many thanks. Downgrading a single library would have been complicated as I am on NixOS.

Why do you think it might not be a good idea though?

@bitozoid
Copy link

@thomaslaich As a enabled it, I started to experience other issues. I don't remember the details.

@g-simmons
Copy link

FWIW I encountered this issue...

Fixed with some trial and error including:

brew uninstall --ignore-dependencies gnupg
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/59edfe598541186430d49cc34f42671e849e2fc9/Formula/gnupg.rb
HOHOMEBREW_NO_INSTALL_CLEANUP=TRUE brew install -s gnupg.rb
brew pin gnupg
  • Adding some settings to emacs config from @benthamite's instructions
(require 'epa-file)
    (setq epg-pinentry-mode 'loopback)
    (epa-file-enable)
    (setq epg-gpg-program "/opt/homebrew/bin/gpg") ; replace with actual path to gpg if different
    (setq plstore-cache-passphrase-for-symmetric-encryption t)
  • org-gcal-sync-tokens-clear and org-gcal--sync-unlock to retrigger the Oauth browser login

  • Restarting Emacs

  • After the above, I was getting a decryption error in the echo area. This was finally resolved by deleting .emacs.d/oauth2-auto.plist and retriggering the oauth flow again.

@benthamite
Copy link
Author

Thanks for outlining the steps you followed. If we identify the exact steps needed to make it work, we should probably create a pull request and add it to the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants