Skip to content

matlab_kernel not reset on reprocessing of Quarto document in VS Code #163

@allefeld

Description

@allefeld

I posted the following previously on Stack Overflow but didn't receive any answers or comments, so I'm trying here:

There is something strange happening when using matlab_kernel in a document processed by the Quarto extension for VS Code.

Example file quarto_matlab_test.qmd:

---
title: test quarto & matlab_kernel
jupyter: matlab
---

```{matlab}
x
```

```{matlab}
x = 2
```
  • When this document is processed for the first time, there is an error message from the first code block about x not being defined, which is correct.

  • If the same document is processed for the second time, the error message disappears and the value x = 2 is reported.

It appears that the Matlab kernel is not reset between Quarto processing runs, and variables as well as other settings are preserved.

The same does not happen with a Python kernel, and it does not happen with matlab_kernel in a notebook (ipynb). I'm not sure whether this is a bug in matlab_kernel, Jupyter, Quarto, or the Quarto extension.

Questions:

  1. How do I debug this, so I can submit a bug report for the software which is the actual culprit? There are so many different pieces involved (see below).

  2. Is there a workaround? A partial solution is to put clear variables into a code block at the top – but as mentioned this also applies to other settings (e.g. format), so it seems that one needs to figure out a sequence of reset commands depending on the document.

Versions:

Python 3.10.4
    jupyter_client 7.3.1
    jupyter_core 4.10.0
    matlab-kernel 0.17.1
    metakernel 0.29.4
    matlabengine 9.13.7
Matlab R2022b Update 4 (9.13.0.2166757)
Quarto 1.2.335
VS Code 1.75.1
    Quarto Extension 1.69.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions