Skip to content

Removing a cell in watch mode prevents redeclaring variables #6594

@Antyos

Description

@Antyos

Describe the bug

When editing a notebook in watch mode, if I delete a cell containing a variable in an external editor while Marimo is in watch mode, Marimo prevents redefining the variable in a new cell:

This cell wasn't run because it has errors
This cell redefines variables from other cells.

'my_var' was also defined by:

  • cell--1

This (annoyingly) happens if I save the file in the external editor without remembering to hit save in Marimo after defining the variable in a new cell.

Steps to reproduce:

  1. Open a Marimo notebook in watch mode
  2. Define a new cell with x=4, run the cell.
  3. Delete the cell in an external editor and save the file. (Alternatively, if you didn't save the notebook in Marimo, just save the file again)
  4. Try defining a new cell in Marimo again with x=3.

This issue is similar, but not a dupe of #1016.

Will you submit a PR?

  • Yes

Environment

Details
{
  "marimo": "0.16.2",
  "editable": false,
  "location": "C:/Users/avg170002/Code/biaxial-bioreactor/code/.venv/Lib/site-packages/marimo",
  "OS": "Windows",
  "OS Version": "11",
  "Processor": "Intel64 Family 6 Model 198 Stepping 2, GenuineIntel",
  "Python Version": "3.13.6",
  "Locale": "en_US",
  "Binaries": {
    "Browser": "--",
    "Node": "v22.18.0"
  },
  "Dependencies": {
    "click": "8.2.1",
    "docutils": "0.22",
    "itsdangerous": "2.2.0",
    "jedi": "0.19.2",
    "markdown": "3.8.2",
    "narwhals": "2.2.0",
    "packaging": "25.0",
    "psutil": "7.0.0",
    "pygments": "2.19.2",
    "pymdown-extensions": "10.16.1",
    "pyyaml": "6.0.2",
    "starlette": "0.47.3",
    "tomlkit": "0.13.3",
    "typing-extensions": "4.15.0",
    "uvicorn": "0.35.0",
    "websockets": "15.0.1"
  },
  "Optional Dependencies": {
    "altair": "5.5.0",
    "duckdb": "1.3.2",
    "nbformat": "5.10.4",
    "openai": "1.102.0",
    "pandas": "2.3.2",
    "polars": "1.32.3",
    "pyarrow": "21.0.0",
    "loro": "1.5.4",
    "pytest": "8.4.1",
    "python-lsp-ruff": "2.2.2",
    "python-lsp-server": "1.13.1",
    "ruff": "0.12.11",
    "sqlglot": "27.9.0"
  },
  "Experimental Flags": {}
}

Code to reproduce

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions