microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.25k stars 274 forks source link

Kernel dies: Error in suppressWarnings(gregexpr("[^\\.\\w:?$@[\\]]+", ... #15697

Open nick-youngblut opened 1 month ago

nick-youngblut commented 1 month ago

Applies To

What happened?

Using the following kernel:

mamba create -n ${JUPYTER_ENV_NAME} \
  python=3.10 jupyterlab ipykernel nb_conda \
  r-irkernel r-renv r-dplyr r-tidyr r-ggplot2 r-glue \
  r-hdf5r r-seuratdisk r-seurat

Notebooks running that R kernel in VS Code will seemingly randomly die with the error:

17:17:20.495 [error] Disposing session as kernel process died ExitCode: 1, Reason: Error in suppressWarnings(gregexpr("[^\\.\\w:?$@[\\]]+", linebuffer, perl = TRUE))[[1L]] : 
  subscript out of bounds
Calls: <Anonymous> ... handle_shell -> complete -> completions -> <Anonymous>
Execution halted

This seems to only happen with my R kernels in which r-seurat is installed.

I'm running VS Code remotely on a SLURM cluster running Ubuntu 22.04.3.

VS Code Version

1.89.1

Jupyter Extension Version

v2024.4.0

Jupyter logs

17:16:54.852 [info] Restart requested ~/projects/SspArc0008_10x_cDNA_longRead/notebooks/scrnaseq/seurat.ipynb
17:16:54.864 [info] Launching Raw Kernel R # R
17:16:56.065 [info] Process Execution: /R --slave -e IRkernel::main() --args /home/~/.local/share/jupyter/runtime/kernel-v2-580106zPwn6FEHcydJ.json
    > cwd: //home/~/projects/SspArc0008_10x_cDNA_longRead/notebooks/scrnaseq
17:16:56.699 [info] Restarted 01d9e79d-76c6-43dc-ac53-791853c796bf
17:16:59.506 [info] Handle Execution of Cells 2 for ~/projects/SspArc0008_10x_cDNA_longRead/notebooks/scrnaseq/seurat.ipynb
17:16:59.557 [info] Cell 2 completed in 0.047s (start: 1715966219510, end: 1715966219557)
17:17:00.132 [info] Handle Execution of Cells 4 for ~/projects/SspArc0008_10x_cDNA_longRead/notebooks/scrnaseq/seurat.ipynb
17:17:03.042 [info] Cell 4 completed in 2.907s (start: 1715966220135, end: 1715966223042)
17:17:05.726 [info] Handle Execution of Cells 6 for ~/projects/SspArc0008_10x_cDNA_longRead/notebooks/scrnaseq/seurat.ipynb
17:17:05.824 [info] Cell 6 completed in 0.094s (start: 1715966225730, end: 1715966225824)
17:17:11.766 [info] Handle Execution of Cells 7 for ~/projects/SspArc0008_10x_cDNA_longRead/notebooks/scrnaseq/seurat.ipynb
17:17:11.767 [info] Cell 7 completed in 0s (start: undefined, end: undefined)
17:17:14.486 [info] Handle Execution of Cells 7 for ~/projects/SspArc0008_10x_cDNA_longRead/notebooks/scrnaseq/seurat.ipynb
17:17:14.486 [info] Cell 7 completed in 0s (start: undefined, end: undefined)
17:17:20.495 [error] Disposing session as kernel process died ExitCode: 1, Reason: Error in suppressWarnings(gregexpr("[^\\.\\w:?$@[\\]]+", linebuffer, perl = TRUE))[[1L]] : 
  subscript out of bounds
Calls: <Anonymous> ... handle_shell -> complete -> completions -> <Anonymous>
Execution halted


### Coding Language and Runtime Version

_No response_

### Language Extension Version (if applicable)

_No response_

### Anaconda Version (if applicable)

_No response_

### Running Jupyter locally or remotely?

Remote
nick-youngblut commented 1 month ago

It seems that this generally occurs when I'm deleting cells or converting cells (markdown <--> code), and copilot tries to auto-complete something right before or after I perform the deletion/transformation operation. I'll try disabling copilot and see if I the kernel still dies.

nick-youngblut commented 1 month ago

Even with copilot disabled, the R kernel will die. However, the issue appears to occur when I'm adding/deleting/transforming cells (e.g., add cell and convert from markdown to code).

DonJayamanne commented 1 month ago

However, the issue appears to occur when I'm adding/deleting/transforming cells (e.g., add cell and convert from markdown to code).

Are you in the middle of some code execution when this happens? Please can you try to repro this issue and share the logs after enabling verbose logging as follows. Please could you enable logging as follows:

nick-youngblut commented 1 month ago

Here's some verbose logs of R kernel crashes:

nick-youngblut commented 1 month ago

I should note that I get the following warning after running Developer: Reload Window:

Cannot find R to use for help, package installation etc. Change setting r.rpath.linux to R path.

I don't want to set my R path in the VS Code settings, since I'm using different R kernels across my running iPython notebooks. For example, I don't want to hardcode my R path to:

{
  "r.rpath.linux": "/path/to/particular/conda/R/environment"
}