IHaskell / IHaskell

A Haskell kernel for the Jupyter project.
MIT License
2.56k stars 258 forks source link

VS Code: stuck after first cell #1506

Open MHellmund opened 1 month ago

MHellmund commented 1 month ago

I think this may be related to https://github.com/IHaskell/IHaskell/issues/1417 . I see the bug described there when using jupyter notebook.

Using the VS Code jupyter extension (with the same python env, jupyter and ihaskell kernel) , evaluating the first code cell shows the result, but the cell stays "busy" and it is impossible (without interrupting the kernel) to evaluate another cell. Other kernels (ipython and ijulia) work.

vaibhavsagar commented 1 month ago

Are you getting log output from IHaskell? I've managed to successfully get it working with VS Code (even though the cell numbers don't always update correctly), so I think something else must be going on.

MHellmund commented 1 month ago
Visual Studio Code (1.90.0, undefined, desktop)
Jupyter Extension Version: 2024.5.0.
Python Extension Version: 2024.8.1.
Pylance Extension Version: 2024.6.1.
Platform: linux (x64).
Workspace folder ~/Haskell/Dao, Home = /home/hellmund
11:36:00.907 [warn] Disposing old controller startUsingPythonInterpreter:'.jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher' for view = 'jupyter-notebook'
11:36:00.908 [warn] Disposing old controller startUsingPythonInterpreter:'.jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher (Interactive)' for view = 'interactive'
11:36:12.615 [info] Starting Kernel (Haskell) for '~/Haskell/Dao/test2.ipynb' (disableUI=true)
11:36:12.623 [info] Launching Raw Kernel Haskell # /home/~/.local/state/cabal/store/ghc-9.6.5/ihaskell-0.11.0.0-e-ihaskell-dd1019b598275fa6fcd86fcc4904be1bb48e1077f48ced4c7a58f30b5d00fad0/bin/ihaskell
11:36:12.627 [info] Process Execution: ~/.local/state/cabal/store/ghc-9.6.5/ihaskell-0.11.0.0-e-ihaskell-dd1019b598275fa6fcd86fcc4904be1bb48e1077f48ced4c7a58f30b5d00fad0/bin/ihaskell kernel /home/~/.local/share/jupyter/runtime/kernel-v2-1301323qMl9Kzhvi4kQ.json --ghclib /home/~/.ghcup/ghc/9.6.5/lib/ghc-9.6.5/lib +RTS -M3g -N2 -RTS
    > cwd: //home/~/Haskell/Dao
11:36:15.640 [warn] Kernel completions not enabled for 'Haskell'. 
To enable Kernel completion for this language please add the following setting 
jupyter.completionTriggerCharacters = {haskell: [<List of characters that will trigger completions>]}. 
For more information please see https://aka.ms/vscodeJupyterCompletion
11:36:15.640 [info] Kernel successfully started
11:36:15.640 [warn] No nbextensions folder found for kernel .haskell./home/~/.local/state/cabal/store/ghc-9.6.5/ihaskell-0.11.0.0-e-ihaskell-dd1019b598275fa6fcd86fcc4904be1bb48e1077f48ced4c7a58f30b5d00fad0/bin/ihaskell././home/~/.local/state/cabal/store/ghc-9.6.5/ihaskell-0.11.0.0-e-ihaskell-dd1019b598275fa6fcd86fcc4904be1bb48e1077f48ced4c7a58f30b5d00fad0/bin/ihaskell#kernel#{connection_file}#--ghclib#/home/~/.ghcup/ghc/9.6.5/lib/ghc-9.6.5/lib#+rts#-m3g#-n2#-rts
11:36:15.642 [warn] Unhandled message found: kernel_info_reply
11:36:15.642 [warn] Unhandled message found: kernel_info_reply
11:36:15.642 [warn] Unhandled message found: kernel_info_reply
11:36:15.642 [warn] Unhandled message found: kernel_info_reply
11:36:55.216 [info] Interrupt kernel execution
11:36:55.216 [info] Interrupt requested ~/Haskell/Dao/test2.ipynb
11:36:55.216 [info] Interrupt kernel execution
11:36:55.216 [info] Interrupting kernel: haskell
11:36:55.216 [info] Interrupting kernel via SIGINT
11:37:05.218 [info] Interrupt requested & sent for ~/Haskell/Dao/test2.ipynb in notebookEditor.
11:37:07.963 [info] Restart requested ~/Haskell/Dao/test2.ipynb
11:37:07.977 [info] Launching Raw Kernel Haskell # /home/~/.local/state/cabal/store/ghc-9.6.5/ihaskell-0.11.0.0-e-ihaskell-dd1019b598275fa6fcd86fcc4904be1bb48e1077f48ced4c7a58f30b5d00fad0/bin/ihaskell
11:37:07.981 [info] Process Execution: ~/.local/state/cabal/store/ghc-9.6.5/ihaskell-0.11.0.0-e-ihaskell-dd1019b598275fa6fcd86fcc4904be1bb48e1077f48ced4c7a58f30b5d00fad0/bin/ihaskell kernel /home/~/.local/share/jupyter/runtime/kernel-v2-1301323h8lr0fva5LHF.json --ghclib /home/~/.ghcup/ghc/9.6.5/lib/ghc-9.6.5/lib +RTS -M3g -N2 -RTS
    > cwd: //home/~/Haskell/Dao
11:37:10.855 [info] Restarted 920d0792-52b9-4ff0-9242-c18614d6e6e4
11:37:51.146 [info] Disposing request as the cell (0) was deleted ~/Haskell/Dao/test2.ipynb
11:37:51.147 [info] Dispose Kernel '~/Haskell/Dao/test2.ipynb' associated with '~/Haskell/Dao/test2.ipynb'
11:37:51.154 [warn] Cell completed with errors (cancelled)
11:37:51.155 [warn] Cancel all remaining cells due to dead kernel
11:38:21.244 [info] Starting Kernel (Haskell) for '~/Haskell/Dao/test2.ipynb' (disableUI=true)
11:38:21.248 [info] Launching Raw Kernel Haskell # /home/~/.local/state/cabal/store/ghc-9.6.5/ihaskell-0.11.0.0-e-ihaskell-dd1019b598275fa6fcd86fcc4904be1bb48e1077f48ced4c7a58f30b5d00fad0/bin/ihaskell
11:38:21.252 [info] Process Execution: ~/.local/state/cabal/store/ghc-9.6.5/ihaskell-0.11.0.0-e-ihaskell-dd1019b598275fa6fcd86fcc4904be1bb48e1077f48ced4c7a58f30b5d00fad0/bin/ihaskell kernel /home/~/.local/share/jupyter/runtime/kernel-v2-1301323wpJFwrtWcwaQ.json --ghclib /home/~/.ghcup/ghc/9.6.5/lib/ghc-9.6.5/lib +RTS -M3g -N2 -RTS
    > cwd: //home/~/Haskell/Dao
11:38:24.110 [warn] Kernel completions not enabled for 'Haskell'. 
To enable Kernel completion for this language please add the following setting 
jupyter.completionTriggerCharacters = {haskell: [<List of characters that will trigger completions>]}. 
For more information please see https://aka.ms/vscodeJupyterCompletion
11:38:24.111 [info] Kernel successfully started
11:38:24.111 [warn] No nbextensions folder found for kernel .haskell./home/~/.local/state/cabal/store/ghc-9.6.5/ihaskell-0.11.0.0-e-ihaskell-dd1019b598275fa6fcd86fcc4904be1bb48e1077f48ced4c7a58f30b5d00fad0/bin/ihaskell././home/~/.local/state/cabal/store/ghc-9.6.5/ihaskell-0.11.0.0-e-ihaskell-dd1019b598275fa6fcd86fcc4904be1bb48e1077f48ced4c7a58f30b5d00fad0/bin/ihaskell#kernel#{connection_file}#--ghclib#/home/~/.ghcup/ghc/9.6.5/lib/ghc-9.6.5/lib#+rts#-m3g#-n2#-rts
11:41:06.953 [info] Interrupt kernel execution
11:41:06.953 [info] Interrupt requested ~/Haskell/Dao/test2.ipynb
11:41:06.953 [info] Interrupt kernel execution
11:41:06.953 [info] Interrupting kernel: haskell
11:41:06.954 [info] Interrupting kernel via SIGINT
11:41:16.955 [info] Interrupt requested & sent for ~/Haskell/Dao/test2.ipynb in notebookEditor.
11:41:22.709 [info] Interrupt kernel execution
11:41:22.709 [info] Interrupt requested ~/Haskell/Dao/test2.ipynb
11:41:22.709 [info] Interrupt kernel execution
11:41:22.709 [info] Interrupting kernel: haskell
11:41:22.709 [info] Interrupting kernel via SIGINT
11:41:22.746 [error] Disposing session as kernel process died ExitCode: undefined, Reason: 
11:41:32.710 [info] Interrupt requested & sent for ~/Haskell/Dao/test2.ipynb in notebookEditor.
11:41:38.778 [error] Error in execution (get message for cell) Error: The kernel 'Haskell' died. Click [here](https://aka.ms/vscodeJupyterKernelCrash) for more info. View Jupyter [log](command:jupyter.viewOutput) for further details.
    > Kernel Id = .haskell./home/~/.local/state/cabal/store/ghc-9.6.5/ihaskell-0.11.0.0-e-ihaskell-dd1019b598275fa6fcd86fcc4904be1bb48e1077f48ced4c7a58f30b5d00fad0/bin/ihaskell././home/~/.local/state/cabal/store/ghc-9.6.5/ihaskell-0.11.0.0-e-ihaskell-dd1019b598275fa6fcd86fcc4904be1bb48e1077f48ced4c7a58f30b5d00fad0/bin/ihaskell#kernel#{connection_file}#--ghclib#/home/~/.ghcup/ghc/9.6.5/lib/ghc-9.6.5/lib#+rts#-m3g#-n2#-rts
    > at Function.verifyKernelState (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.5.0-linux-x64/dist/extension.node.js:314:79702)
    > originalException = undefined
vaibhavsagar commented 4 weeks ago

Can you also include the Jupyter log output, as alluded to here?

11:41:38.778 [error] Error in execution (get message for cell) Error: The kernel 'Haskell' died. Click [here](https://aka.ms/vscodeJupyterKernelCrash) for more info. View Jupyter [log](command:jupyter.viewOutput) for further details.
MHellmund commented 4 weeks ago

I am sorry, the log is a bit misleading. The kernel died since I stopped the restarting. Anyway, this is already the jupyter log output.

Since I am not sure if my ghcup/cabal-based installation is OK, I used another machine with Archlinux and installed the archlinux distribution packages for ghc, ihaskell, jupyter. The result is esssentially the same. In VS Code, the first cell hangs after producing output and further cells can't be executed:

ihaskell

Please let me know if there is a way to produce more logging/debug output. (I really like to work with jupyter nortebooks in a real editor instead of a browser.)

MHellmund commented 4 weeks ago

Some more debug messages:

16:40:17.462 [debug] Handle Execution of Cells 0 for ~/Haskell/Dao/test2.ipynb
16:40:17.463 [trace] Cell Index:0 sent to kernel
16:40:17.463 [trace] [AnyMessage Event] [send] [2078238] {"buffers":[],"channel":"shell","content":{"silent":false,"store_history":true,"user_expressions":{},"allow_stdin":true,"stop_on_error":false,"code":"2+3"},"header":{"date":"2024-06-18T14:40:17.463Z","msg_id":"b3ece330-00b3-4354-b0eb-127611446e28","msg_type":"execute_request","session":"a4d1c93c-00ce-411d-a871-e8059b6966e2","username":"6dbd5838-f7d3-4f1a-90a7-e9873a7dcf56","version":"5.2"},"metadata":{"cellId":"vscode-notebook-cell:/home/~/Haskell/Dao/test2.ipynb#W0sZmlsZQ%3D%3D"},"parent_header":{}}
16:40:17.464 [trace] [AnyMessage Event] [recv] [2078238] {"header":{"msg_id":"6e67a462-1b1e-483d-88b7-53ba99f05d75","msg_type":"kernel_info_reply","session":"a4d1c93c-00ce-411d-a871-e8059b6966e2","username":"6dbd5838-f7d3-4f1a-90a7-e9873a7dcf56","version":"5.0"},"parent_header":{"msg_id":"9b1fb5c4-a1bd-46a5-a651-c6cfc813879d","msg_type":"kernel_info_request","session":"a4d1c93c-00ce-411d-a871-e8059b6966e2","username":"6dbd5838-f7d3-4f1a-90a7-e9873a7dcf56","version":"5.0"},"metadata":{},"content":{"protocol_version":"5.0","banner":"IHaskell 0.11.0.0 GHC 9.6.5","implementation":"IHaskell","implementation_version":"0.11.0.0","language_info":{"codemirror_mode":"ihaskell","file_extension":".hs","mimetype":"text/x-haskell","name":"haskell","pygments_lexer":"Haskell","version":"9.6.5"},"status":"ok"},"idents":[],"buffers":[],"channel":"shell"}
16:40:17.479 [trace] [AnyMessage Event] [recv] [2078238] {"header":{"msg_id":"4705c91a-861f-4b09-91e9-ac7e3edb8946","msg_type":"status","session":"a4d1c93c-00ce-411d-a871-e8059b6966e2","username":"6dbd5838-f7d3-4f1a-90a7-e9873a7dcf56","version":"5.0"},"parent_header":{"msg_id":"b3ece330-00b3-4354-b0eb-127611446e28","msg_type":"execute_request","session":"a4d1c93c-00ce-411d-a871-e8059b6966e2","username":"6dbd5838-f7d3-4f1a-90a7-e9873a7dcf56","version":"5.0"},"metadata":{},"content":{"execution_state":"busy"},"idents":[{"type":"Buffer","data":[102,101,97,49,98,51,53,52,45,52,55,57,48,45,52,50,49,51,45,57,52,48,48,45,48,53,97,53,56,100,100,49,101,99,57,55]}],"buffers":[],"channel":"iopub"}
16:40:17.479 [trace] [AnyMessage Event] [recv] [2078238] {"header":{"msg_id":"44dc6201-af52-400b-899e-22f495bcb35d","msg_type":"execute_input","session":"a4d1c93c-00ce-411d-a871-e8059b6966e2","username":"6dbd5838-f7d3-4f1a-90a7-e9873a7dcf56","version":"5.0"},"parent_header":{"msg_id":"b3ece330-00b3-4354-b0eb-127611446e28","msg_type":"execute_request","session":"a4d1c93c-00ce-411d-a871-e8059b6966e2","username":"6dbd5838-f7d3-4f1a-90a7-e9873a7dcf56","version":"5.0"},"metadata":{},"content":{"execution_count":1,"code":"2+3"},"idents":[{"type":"Buffer","data":[102,101,97,49,98,51,53,52,45,52,55,57,48,45,52,50,49,51,45,57,52,48,48,45,48,53,97,53,56,100,100,49,101,99,57,55]}],"buffers":[],"channel":"iopub"}
16:40:17.479 [trace] Start cell 0 execution @ 1718721617479 (clear output)
16:40:17.480 [debug] Kernel acknowledged execution of cell 0 @ 1718721617479
16:40:17.567 [debug] KernelProcess error 2078238: DEBUG: Expression:
2+3

16:40:17.575 [debug] KernelProcess error 2078238: DEBUG: Can Display: F
16:40:17.575 [debug] KernelProcess error 2078238: alse
DEBUG: Is Widget: False
DEBUG: Is Declaration: False
DEBUG: State
16:40:17.575 [debug] KernelProcess error 2078238: ment:
2+3
16:40:17.763 [debug] KernelProcess error 2078238: DEBUG: Names: ["it"]
DEBUG: Statement
16:40:17.764 [debug] KernelProcess error 2078238: :
let it1 = it

16:40:17.765 [trace] [AnyMessage Event] [recv] [2078238] {"header":{"msg_id":"71bab0fb-3c84-4170-ae5b-d9868fffa4b0","msg_type":"display_data","session":"a4d1c93c-00ce-411d-a871-e8059b6966e2","username":"6dbd5838-f7d3-4f1a-90a7-e9873a7dcf56","version":"5.0"},"parent_header":{"msg_id":"b3ece330-00b3-4354-b0eb-127611446e28","msg_type":"execute_request","session":"a4d1c93c-00ce-411d-a871-e8059b6966e2","username":"6dbd5838-f7d3-4f1a-90a7-e9873a7dcf56","version":"5.0"},"metadata":{},"content":{"metadata":{},"data":{"text/plain":"5"}},"idents":[{"type":"Buffer","data":[102,101,97,49,98,51,53,52,45,52,55,57,48,45,52,50,49,51,45,57,52,48,48,45,48,53,97,53,56,100,100,49,101,99,57,55]}],"buffers":[],"channel":"iopub"}
16:40:17.884 [debug] KernelProcess error 2078238: DEBUG: Names: ["it1"]

16:40:17.886 [trace] [AnyMessage Event] [recv] [2078238] {"header":{"msg_id":"9105afeb-9ace-45de-816a-08ae4d22494b","msg_type":"status","session":"a4d1c93c-00ce-411d-a871-e8059b6966e2","username":"6dbd5838-f7d3-4f1a-90a7-e9873a7dcf56","version":"5.0"},"parent_header":{"msg_id":"b3ece330-00b3-4354-b0eb-127611446e28","msg_type":"execute_request","session":"a4d1c93c-00ce-411d-a871-e8059b6966e2","username":"6dbd5838-f7d3-4f1a-90a7-e9873a7dcf56","version":"5.0"},"metadata":{},"content":{"execution_state":"idle"},"idents":[{"type":"Buffer","data":[102,101,97,49,98,51,53,52,45,52,55,57,48,45,52,50,49,51,45,57,52,48,48,45,48,53,97,53,56,100,100,49,101,99,57,55]}],"buffers":[],"channel":"iopub"}

I tried to compare this with another kernel (ijulia) and that kernel sends after the execution results and before the idle message another message over the shell channel, with type execute_reply , saying: status:ok, execution_count:1.