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

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

Closed
1 of 2 tasks
nick-youngblut opened this issue May 17, 2024 · 9 comments
Closed
1 of 2 tasks
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster notebook-kernel Kernels issues (start/restart/switch/execution, install ipykernel)

Comments

@nick-youngblut
Copy link

Applies To

  • Notebooks (.ipynb files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

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 nick-youngblut added the bug Issue identified by VS Code Team member as probable bug label May 17, 2024
@nick-youngblut
Copy link
Author

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
Copy link
Author

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
Copy link
Contributor

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:

  • Open settings & go into Jupyter->Logging
  • Change the value to verbose
  • Reload VS Code,
  • Attempt to repro the issue & then copy the output from the Jupyter output panel.

@DonJayamanne DonJayamanne added info-needed Issue requires more information from poster notebook-kernel Kernels issues (start/restart/switch/execution, install ipykernel) labels May 20, 2024
@nick-youngblut
Copy link
Author

nick-youngblut commented May 22, 2024

@nick-youngblut
Copy link
Author

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"
}

@DonJayamanne
Copy link
Contributor

It seems that this generally occurs when I'm deleting cells or converting cells

Yes. execution will be terminated when a cell is deleted/transformed (same as deleting and inserting). I.e. if a cell is queued for execution or is in the middle of execution, then the kernel will be interrupted.
Also, if the kernel cannot handle interruption (not sure if R kernel can handle is well or not) it can crash.
its upto the kernel.

My suggestion, try this again without using copilot and do not make changes to cells (such as deleting/moving cells).
If you cannot repro this, then its a result of deletion of cells (e.g. copilot might end up doing the same thing to transform cells)

@nick-youngblut
Copy link
Author

Thanks for the suggestion!

Due to various issues with kernels restarting after losing the ssh connection with VS Code running the kernels on our SLURM HPC, we no longer use Jupyter via VS Code. We often need to run long-running jobs, so we can't have the kernel dying when we lose our ssh connection.

@DonJayamanne
Copy link
Contributor

@nick-youngblut I guess you are after a fix for this #3998
I'm sorry you are running into this issue, hopefully #3998 will resolve the issues for you.

Closing this issue for now.

@nick-youngblut
Copy link
Author

No worries. Running Jupyter directly is working well -- at least for now.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster notebook-kernel Kernels issues (start/restart/switch/execution, install ipykernel)
Projects
None yet
Development

No branches or pull requests

2 participants