MyST-NB icon indicating copy to clipboard operation
MyST-NB copied to clipboard

Unclear error message when both MyST-NB and MyST-parser are enabled

Open liz-is opened this issue 1 year ago • 0 comments

Describe the bug

context When I enabled MyST-NB on a project that was already using MyST parser, I got a rather cryptic error message.

expectation I expected to be able to have both extensions enabled at the same time, since MyST-NB uses the MyST parser.

bug This is the Sphinx log with the error message:

# Platform:         darwin; (macOS-14.7.1-arm64-arm-64bit)
# Sphinx version:   8.1.3
# Python version:   3.12.4 (CPython)
# Docutils version: 0.21.2
# Jinja2 version:   3.1.5
# Pygments version: 2.18.0

# Last messages:


# Loaded extensions:


# Traceback:
Traceback (most recent call last):
  File "/Users/.venv/lib/python3.12/site-packages/sphinx/cmd/build.py", line 496, in build_main
    app = Sphinx(
          ^^^^^^^
  File "/Users/.venv/lib/python3.12/site-packages/sphinx/application.py", line 256, in __init__
    self.setup_extension(extension)
  File "/Users/.venv/lib/python3.12/site-packages/sphinx/application.py", line 437, in setup_extension
    self.registry.load_extension(self, extname)
  File "/Users/.venv/lib/python3.12/site-packages/sphinx/registry.py", line 466, in load_extension
    metadata = setup(app)
               ^^^^^^^^^^
  File "/Users/.venv/lib/python3.12/site-packages/myst_nb/__init__.py", line 10, in setup
    return sphinx_setup(app)
           ^^^^^^^^^^^^^^^^^
  File "/Users/.venv/lib/python3.12/site-packages/myst_nb/sphinx_ext.py", line 49, in sphinx_setup
    setup_myst_parser(app)
  File "/Users/.venv/lib/python3.12/site-packages/myst_parser/sphinx_ext/main.py", line 49, in setup_sphinx
    app.registry.transforms.remove(SphinxUnreferencedFootnotesDetector)
ValueError: list.remove(x): x not in list

problem This is the same issue as discussed here. The solution is to only enable MyST-NB, not both at the same time. However this is not obvious from the error message, and there's no mention of this on the MyST-NB "getting started" page. It would be good to have a more informative error message and/or this mentioned in the documentation, as I'm sure there will be other people with the same issue. I was close to giving up on using MyST-NB until I found the issue linked above!

Reproduce the bug

# in conf.py
extensions = [
    "myst_parser",
    "myst_nb"
]

List your environment

myst_nb version '1.1.2' myst_parser version '4.0.0'

liz-is avatar Jan 20 '25 16:01 liz-is