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

emacs 30, macos, zmq error #542

Closed
danielpopescu opened this issue Jun 24, 2024 · 15 comments
Closed

emacs 30, macos, zmq error #542

danielpopescu opened this issue Jun 24, 2024 · 15 comments

Comments

@danielpopescu
Copy link

Hello,

Just started getting this error (org version 9.7.5, latest of everything, macos, native compilation):

error in process filter: progn: Error in ZMQ subprocess: wrong-type-argument, (listp #[(ctx) ((setq load-path (cons "/.emacs.d/elpa/jupyter-20240420.1918/" load-path)) (require 'jupyter-ioloop) (setq jupyter-ioloop-poller (zmq-poller)) (setq jupyter-ioloop-stdin (let ((sock (zmq-socket ctx zmq-PAIR))) (prog1 sock (zmq-connect sock (format "tcp://127.0.0.1:%s" 51351))))) (zmq-poller-add jupyter-ioloop-poller jupyter-ioloop-stdin zmq-POLLIN) (let (events) (condition-case nil (progn (setq jupyter-channel-ioloop-session (let ((conn-info nil) (id "ee0db486-5825-441f-b599-a03b84903670") (key "69613b3a-165b-4715-9789-747ded51ac6b")) (progn (record 'jupyter-session conn-info id key)))) (require 'jupyter-channel-ioloop) (require 'jupyter-zmq-channel-ioloop) (setq jupyter-ioloop-post-hook (cons 'jupyter-zmq-channel-ioloop--recv-messages jupyter-ioloop-post-hook)) (let* ((--cl-var-- '(:shell :stdin :iopub :control)) (channel nil)) (while (consp --cl-var--) (setq channel (car --cl-var--)) (if (object-assoc channel :type jupyter-channel-ioloop-channels) (progn) (setq jupyter-channel-ioloop-channels (cons (jupyter-zmq-channel :session jupyter-channel-ioloop-session :type channel) jupyter-channel-ioloop-channels))) (setq --cl-var-- (cdr --cl-var--))) nil) (setq jupyter-ioloop-pre-hook (mapcar #'(lambda (f) (if (symbolp f) (progn (setq f (symbol-function f)))) (if (byte-code-function-p f) nil (byte-compile f))) (append jupyter-ioloop-pre-hook 'nil))) (zmq-prin1 '(start)) (let ((on-stdin (byte-compile #'(lambda nil (let* ((cmd (read (zmq-recv jupyter-ioloop-stdin))) (res (if (consp cmd) (let* ((x37 (car-safe cmd))) (cond ((eq x37 'send) (let* ((x38 (cdr-safe cmd))) (if (consp x38) (let* ((x39 (car-safe x38)) (x40 (funcall #'(lambda (x) (or (object-assoc x :type jupyter-channel-ioloop-channels) (error "Channel not alive (%s)" x))) x39)) (x41 (cdr-safe x38))) (if (consp x41) (let* ((x42 (car-safe x41)) (x43 (cdr-safe x41))) (if (consp x43) (let* ((x44 (car-safe x43)) (x45 (cdr-safe x43))) (if (consp x45) (let* ((x46 (car-safe x45)) (x47 (cdr-safe x45))) (if (null x47) (let ((channel x40) (msg-type x42) (msg x44) (msg-id x46)) (list 'sent (eieio-oref channel 'type) (jupyter-send channel msg-type msg msg-id))) (let nil (error "Unhandled command %s" cmd)))) (let nil (error "Unhandled command %s" cmd)))) (let nil (error "Unhandled command %s" cmd)))) (let nil (error "Unhandled command %s" cmd)))) (let nil (error "Unhandled command %s" cmd))))) ((eq x37 'stop-channel) (let* ((x48 (cdr-safe cmd))) (if (consp x48) (let* ((x49 (car-safe x48)) (x50 (cdr-safe x48))) (if (null x50) (let ((type x49)) (let ((channel (object-assoc type :type jupyter-channel-ioloop-channels))) (if (and channel (jupyter-alive-p channel)) (progn (jupyter-stop channel))) (list 'stop-channel type))) (let nil (error "Unhandled command %s" cmd)))) (let nil (error "Unhandled command %s" cmd))))) ((eq x37 'start-channel) (let* ((x51 (cdr-safe cmd))) (if (consp x51) (let* ((x52 (car-safe x51)) (x53 (funcall #'(lambda (x) (or (object-assoc x :type jupyter-channel-ioloop-channels) (error "Channel not alive (%s)" x))) x52)) (x54 (cdr-safe x51))) (if (consp x54) (let* ((x55 (car-safe x54)) (x56 (cdr-safe x54))) (if (null x56) (let ((channel x53) (endpoint x55)) (if (jupyter-alive-p channel) (progn (jupyter-stop channel))) (eieio-oset channel 'endpoint endpoint) (let ((identity (let* ((cl-x jupyter-channel-ioloop-session)) (progn (or (let* ((cl-x cl-x)) (progn (and (memq (type-of cl-x) cl-struct-jupyter-session-tags) t))) (signal 'wrong-type-argument (list 'jupyter-session cl-x))) (aref cl-x 2))))) (jupyter-start channel :identity identity)) (list 'start-channel (eieio-oref channel 'type))) (let nil (error "Unhandled command %s" cmd)))) (let nil (error "Unhandled command %s" cmd)))) (let nil (error "Unhandled command %s" cmd))))) ((eq x37 'timer) (let* ((x57 (cdr-safe cmd))) (if (consp x57) (let* ((x58 (car-safe x57)) (x59 (cdr-safe x57))) (if (consp x59) (let* ((x60 (car-safe x59)) (x61 (cdr-safe x59))) (if (consp x61) (let* ((x62 (car-safe x61)) (x63 (cdr-safe x61))) (if (null x63) (let ((id x58) (period x60) (cb x62)) (prog1 nil (let ((timer (run-at-time 0.0 period (byte-compile cb)))) (puthash id timer jupyter-ioloop-timers)))) (let nil (error "Unhandled command %s" cmd)))) (let nil (error "Unhandled command %s" cmd)))) (let nil (error "Unhandled command %s" cmd)))) (let nil (error "Unhandled command %s" cmd))))) ((eq x37 'callback) (let* ((x64 (cdr-safe cmd))) (if (consp x64) (let* ((x65 (car-safe x64)) (x66 (cdr-safe x64))) (if (null x66) (let ((cb x65)) (prog1 nil (setq jupyter-ioloop-timeout 0) (add-hook 'jupyter-ioloop-pre-hook (byte-compile cb) 'append))) (let nil (error "Unhandled command %s" cmd)))) (let nil (error "Unhandled command %s" cmd))))) ((eq x37 'quit) (let* ((x67 (cdr-safe cmd))) (if (null x67) (let nil (signal 'quit nil)) (let nil (error "Unhandled command %s" cmd))))) (t (let nil (error "Unhandled command %s" cmd))))) (let nil (error "Unhandled command %s" cmd))))) (if (and res (listp res)) (progn (zmq-prin1 res)))))))) (while t (run-hooks 'jupyter-ioloop-pre-hook) (setq events (condition-case nil (zmq-poller-wait-all jupyter-ioloop-poller jupyter-ioloop-nsockets jupyter-ioloop-timeout) ((zmq-EAGAIN zmq-EINTR zmq-ETIMEDOUT) nil))) (let ((stdin-event (zmq-assoc jupyter-ioloop-stdin events))) (if stdin-event (progn (setq events (delq stdin-event events)) (funcall on-stdin)))) (run-hook-with-args 'jupyter-ioloop-post-hook events)))) (quit (mapc #'jupyter-stop jupyter-channel-ioloop-channels) (zmq-prin1 '(quit)))))) nil])

Any ideas?

@mk0417
Copy link

mk0417 commented Jun 25, 2024

It should be due to the the new commit of Emacs 30. Similar issue here: #540

@danielpopescu
Copy link
Author

Thank you!

If I turn zmq off with (setq jupyter-use-zmq nil)

then I get this (on macos, on linux it works fine):

Launching notebook process on port 8888...done
progn: Jupyter REST API error: 404, "Not found"

Any ideas?
Ty

@danielpopescu
Copy link
Author

btw, emacs-mirror/emacs@f2bccae is probably not going away.. so emacs-zmq might need to be fixed to work with this change?

@danielpopescu
Copy link
Author

Thank you!

If I turn zmq off with (setq jupyter-use-zmq nil)

then I get this (on macos, on linux it works fine):

Launching notebook process on port 8888...done progn: Jupyter REST API error: 404, "Not found"

Any ideas? Ty

It appears that emacs jupyter doesn't work with jupyter_server >= 2.x release....
Maybe this API change is causing the issue jupyter-server/jupyter_server#1047 ?

@singletS
Copy link

singletS commented Jun 28, 2024

I'm also getting "Error in ZMQ subprocess: wrong-type-argument" on linux (debian) GNU Emacs 30.0.50 Development version 57c0549 which pre-dates commit f2bccae by a couple months. This setup used to work fine, but after an update of several melpa/elpa packages now no longer works. Org 9.6.15, juypter-server 2.14.0, emacs-zmq 1.0.0.

@nnicandro
Copy link
Collaborator

I believe I have found a fix for the wrong-type-argument error caused by f2bccae which I will push to emacs-zmq when I get the chance.

@danielpopescu As for the REST API error, there may be more information in the notebook buffer. Could you list here the contents of the *jupyter-notebook* buffer that gets created when you specify jupyter-use-zmq to nil.

@gmoutso
Copy link

gmoutso commented Jul 5, 2024

@danielpopescu I also had a 404 error once on a remote jupyter server I was using (that had password and token disabled). I don't remember the details but it was related to http://jupyterserver:port/login missing when jupyter-api-request-xsrf-cookie was called. I found this by looking at the log of the jupyter server. I solved it like this:

(defun gm/jupyter-api-request-xsrf-cookie-error-advice (func &rest args)
  (condition-case nil
      (apply func args)
    (jupyter-api-http-error nil)))
(advice-add 'jupyter-api-request-xsrf-cookie :around #'gm/jupyter-api-request-xsrf-cookie-error-advice)

@danielpopescu
Copy link
Author

@danielpopescu I also had a 404 error once on a remote jupyter server I was using (that had password and token disabled). I don't remember the details but it was related to http://jupyterserver:port/login missing when jupyter-api-request-xsrf-cookie was called. I found this by looking at the log of the jupyter server. I solved it like this:

(defun gm/jupyter-api-request-xsrf-cookie-error-advice (func &rest args)
  (condition-case nil
      (apply func args)
    (jupyter-api-http-error nil)))
(advice-add 'jupyter-api-request-xsrf-cookie :around #'gm/jupyter-api-request-xsrf-cookie-error-advice)

This fixed the error. TY!

@danielpopescu
Copy link
Author

I believe I have found a fix for the wrong-type-argument error caused by f2bccae which I will push to emacs-zmq when I get the chance.

@danielpopescu As for the REST API error, there may be more information in the notebook buffer. Could you list here the contents of the *jupyter-notebook* buffer that gets created when you specify jupyter-use-zmq to nil.

Excellent. Looking forward to the fix!

As far as 404 error, @gmoutso proposed fixed works in my case as well.... (using latest 3.12 python, emacs 30.0.60, and macos).

@danielpopescu
Copy link
Author

I believe I have found a fix for the wrong-type-argument error caused by f2bccae which I will push to emacs-zmq when I get the chance.

@danielpopescu As for the REST API error, there may be more information in the notebook buffer. Could you list here the contents of the *jupyter-notebook* buffer that gets created when you specify jupyter-use-zmq to nil.

Just updated to the latest emacs zmq... not sure if it was supposed to fix this issue, but now there is a new issue:

"
Starting python3 kernel process...done
Launching python3 kernel...done
Requesting kernel info...
defconst: Symbol’s value as variable is void: zmq-REQ

"

ty

@nnicandro
Copy link
Collaborator

Can you give a call to zmq-load to see if you can get it working. I think I know what the problem is, I'll take a look. Thanks.

@danielpopescu
Copy link
Author

danielpopescu commented Jul 16, 2024

Can you give a call to zmq-load to see if you can get it working. I think I know what the problem is, I'll take a look. Thanks.

I did and actually build zmq from scratch, after which:

Compilation finished
Loading /Users/dpo/.emacs.d/elpa/zmq-20240715.2122/emacs-zmq (module)...done
nil [2 times]
Executing Python code block at position 421...
Launching python3 kernel...
Starting python3 kernel process...done
Launching python3 kernel...done
Requesting kernel info...
error in process filter: zmq--subprocess-filter: Error in ZMQ subprocess: void-function, (zmq-mesage-more-p)
error in process filter: Error in ZMQ subprocess: void-function, (zmq-mesage-more-p)
Quit [2 times]

Hope this helps...

@nnicandro
Copy link
Collaborator

Looks like a typo, it's mesage, but should be message.

@nnicandro
Copy link
Collaborator

Go ahead and give it another try. I've added zmq-load calls in the latest Emacs-Jupyter where approriate so that should no longer be an issue and I've fixed the typo in Emacs-ZMQ.

@mk0417
Copy link

mk0417 commented Jul 16, 2024

Thank you @nnicandro , I just updated and it works fine for me.

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

5 participants