fredokun / cl-jupyter

An enhanced interactive Shell for Common Lisp (based on the Jupyter protocol)
BSD 2-Clause "Simplified" License
199 stars 29 forks source link

Looping kernel--setting up lisp for the kernel? #36

Closed jordana309 closed 5 years ago

jordana309 commented 6 years ago

I am new to lisp, but more familiar with Jupyter, so I thought I'd try to learn lisp in Jupyter. However, following instructions on quicklisp.org, I found that the kernel looped repeatedly. I thought maybe the system load causes problems, so I tried again with the following commands.

sudo apt-get install sbcl
cd ~/Codes/src
curl -O https://beta.quicklisp.org/quicklisp.lisp
curl -O https://beta.quicklisp.org/quicklisp.lisp.asc
gpg --verify quicklisp.lisp.asc quicklisp.lisp
sbcl --load quicklisp.lisp
   (quicklisp-quickstart:install :path "~/Codes/quicklisp/")
   (ql:add-to-init-file)
   (quit)
git clone https://github.com/fredokun/cl-jupyter
cd cl-jupyter
python3 ./install-cl-jupyter.py
sbcl --load ./cl-jupyter.lisp

Firing this up in Jupyter gave me the following output:

Kernel started: 53aaaa7d-75d1-4ba2-b3ff-85785d1af71e
[I 20:26:37.142 NotebookApp] Adapting to protocol v5.1 for kernel 53aaaa7d-75d1-4ba2-b3ff-85785d1af71e
[I 20:26:44.391 NotebookApp] Starting buffering for 53aaaa7d-75d1-4ba2-b3ff-85785d1af71e:126c1d0ee4f34ffaafd7cc1b1c9c9073
[I 20:26:44.802 NotebookApp] Kernel shutdown: 53aaaa7d-75d1-4ba2-b3ff-85785d1af71e
This is SBCL 1.3.1.debian, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
[I 20:26:44.840 NotebookApp] Kernel started: e6bb4c07-ce8d-4e26-9ab6-413844cf0b7c
To load "cl-jupyter":
  Load 1 ASDF system:
    cl-jupyter
; Loading "cl-jupyter"
.................

cl-jupyter: an enhanced interactive Common Lisp REPL
(Version 0.7 - Jupyter protocol v.5.0)
--> (C) 2014-2015 Frederic Peschanski (cf. LICENSE)

kernel configuration = ((shell_port . 37095) (iopub_port . 34819)
                        (stdin_port . 49001) (control_port . 33311)
                        (hb_port . 39983) (ip . 127.0.0.1)
                        (key . 60c9347d-d949c6e44d2f7cfd9fadc901)
                        (transport . tcp) (signature_scheme . hmac-sha256)
                        (kernel_name . lisp))
While evaluating the form starting at line 50, column 0
  of #P"/home/jordan/Codes/src/cl-jupyter/cl-jupyter.lisp":
Unhandled SB-KERNEL::UNDEFINED-ALIEN-FUNCTION-ERROR in thread #<SB-THREAD:THREAD
                                                                "main thread" RUNNING
                                                                 {100399D2B3}>:
  The alien function "zmq_ctx_new" is undefined.

Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {100399D2B3}>
0: ("undefined function")
1: (PZMQ:CTX-NEW)
2: (KERNEL-START)
3: (SB-INT:SIMPLE-EVAL-IN-LEXENV (KERNEL-START) #<NULL-LEXENV>)
4: (SB-EXT:EVAL-TLF (KERNEL-START) 5 NIL)
5: ((LABELS SB-FASL::EVAL-FORM :IN SB-INT:LOAD-AS-SOURCE) (KERNEL-START) 5)
6: ((LAMBDA (SB-KERNEL:FORM &KEY :CURRENT-INDEX &ALLOW-OTHER-KEYS) :IN SB-INT:LOAD-AS-SOURCE) (KERNEL-START) :CURRENT-INDEX 5)
7: (SB-C::%DO-FORMS-FROM-INFO #<CLOSURE (LAMBDA (SB-KERNEL:FORM &KEY :CURRENT-INDEX &ALLOW-OTHER-KEYS) :IN SB-INT:LOAD-AS-SOURCE) {10058F2B4B}> #<SB-C::SOURCE-INFO {10058F2B03}> SB-C::INPUT-ERROR-IN-LOAD)
8: (SB-INT:LOAD-AS-SOURCE #<SB-INT:FORM-TRACKING-STREAM for "file /home/jordan/Codes/src/cl-jupyter/cl-jupyter.lisp" {10058EFAD3}> :VERBOSE NIL :PRINT NIL :CONTEXT "loading")
9: ((FLET SB-FASL::LOAD-STREAM :IN LOAD) #<SB-INT:FORM-TRACKING-STREAM for "file /home/jordan/Codes/src/cl-jupyter/cl-jupyter.lisp" {10058EFAD3}> NIL)
10: (LOAD #P"/home/jordan/Codes/src/cl-jupyter/cl-jupyter.lisp" :VERBOSE NIL :PRINT NIL :IF-DOES-NOT-EXIST T :EXTERNAL-FORMAT :DEFAULT)
11: (SB-IMPL::PROCESS-EVAL/LOAD-OPTIONS ((:LOAD . "/home/jordan/Codes/src/cl-jupyter/cl-jupyter.lisp") (:QUIT)))
12: (SB-IMPL::TOPLEVEL-INIT)
13: ((FLET #:WITHOUT-INTERRUPTS-BODY-82 :IN SB-EXT:SAVE-LISP-AND-DIE))
14: ((LABELS SB-IMPL::RESTART-LISP :IN SB-EXT:SAVE-LISP-AND-DIE))

unhandled condition in --disable-debugger mode, quitting

then it restarted. Thoughts of what I could try to get up and running? I'm guessing I need to do more to configure quicklisp, but I'm not sure what to do there.

fredokun commented 6 years ago

Given the error trace, it seems that the zmq dependency is not satisfied... Cl-jupyter depends on pzmq and there's a "painful" dependency on the zmq library there. I think installing libzmq3-dev or libzmq4-dev should do the trick on linux.

jordana309 commented 6 years ago

Thank you--that did it! Well, by "did it", I mean it allowed the kernel to run and sbcl to run a little longer. However, I got a weird error when I tried to run the kernel. First, when starting the kernel up the first time, it died and gave me the following:

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
[W 21:13:45.108 NotebookApp] Timeout waiting for kernel_info reply from b46696b7-173f-461c-b0e1-a7a8ccee6f2b
To load "cl-jupyter":
  Load 1 ASDF system:
    cl-jupyter
; Loading "cl-jupyter"
.................

cl-jupyter: an enhanced interactive Common Lisp REPL
(Version 0.7 - Jupyter protocol v.5.0)
--> (C) 2014-2015 Frederic Peschanski (cf. LICENSE)

kernel configuration = ((shell_port . 45213) (iopub_port . 54103)
                        (stdin_port . 39053) (control_port . 39897)
                        (hb_port . 33257) (ip . 127.0.0.1)
                        (key . cb380733-8aa7b5291cdb3bce919e06fe)
                        (transport . tcp) (signature_scheme . hmac-sha256)
                        (kernel_name . lisp))
[Hearbeat] starting...
[Heartbeat] thread started
[Kernel] Entering mainloop ...
[Shell] loop started
CORRUPTION WARNING in SBCL pid 10628(tid 140737353963264):
Memory fault at (nil) (pc=0x1000a5d897, sp=0x7ffff22b0518)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
CORRUPTION WARNING in SBCL pid 10628(tid 140737353963264):
Memory fault at 0x7974697467 (pc=0x10014b05a2, sp=0x7ffff22b0298)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
CORRUPTION WARNING in SBCL pid 10628(tid 140737353963264):
Memory fault at 0x7974697467 (pc=0x10014b05a2, sp=0x7ffff22b0018)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
INFO: Control stack guard page unprotected
CORRUPTION WARNING in SBCL pid 10628(tid 140737353963264):
Enabling blocked gc signals to allow returning to Lisp without risking
gc deadlocks. Since GC signals are only blocked in signal handlers when 
they are not safe to interrupt at all, this is a pretty severe occurrence.

The integrity of this image is possibly compromised.
Continuing with fingers crossed.
fatal error encountered in SBCL pid 10628(tid 140737353963264):
Control stack exhausted, fault: 0x8, PC: 0x40e3ed

Then, it restarted and entered the main loop and ran fine. I tried (print "hello world"), and it gave me the following output before restarting the kernel:

Bye bye.
CORRUPTION WARNING in SBCL pid 10698(tid 140737353963264):
Memory fault at 0xfffffffffffffff9 (pc=0x10014b05a2, sp=0x7ffff249f9f8)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
CORRUPTION WARNING in SBCL pid 10698(tid 140737353963264):
Memory fault at 0xfffffffffffffff9 (pc=0x10014b05a2, sp=0x7ffff249f778)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
fatal error encountered in SBCL pid 10698(tid 140737353963264):
%PRIMITIVE HALT called; the party is over.

Does this look like I messed up something else trying to set up the kernel, or did I goof up setting up sbcl?

fredokun commented 6 years ago

Maybe 1.3.1 is tool old ? Also, I remember I had that kind of error when trying on a mac, and Clozure CL (CCL) was more stable (but it seems you're on linux ?) ...

jordana309 commented 6 years ago

K, I started with a clean Ubuntu install before I installed codes that messed up my compilers. Everything ran fine using your instructions in readme. I'm not sure what was up, but I think those other codes messed up something in my system.