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

AttributeError: 'CheckExternalLinksBuilder' object has no attribute 'current_docname' #2122

Open
scottyhq opened this issue Feb 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@scottyhq
Copy link

Describe the bug

context
jupyter-book build ./ --builder linkcheck results in AttributeError: 'CheckExternalLinksBuilder' object has no attribute 'current_docname'

expectation
I expect an error message that indicates version incompatibility in some way (though maybe there is nothing JupyterBook can do here and it's really the responsibility of the sphinx extension that seems to lead to this error).

bug

This appears to arise from the sphinx-exercise extension that is incompatible with sphinx>6 but does not pin the dependency and a fresh install of jupyterbook=1 installs sphinx=7 executablebooks/sphinx-exercise#64 (comment)

Traceback (most recent call last):
  File "/Users/scott/miniforge3/envs/xarray-tutorial/lib/python3.12/site-packages/sphinx_exercise/post_transforms.py", line 189, in run
    node = resolve_solution_title(self.app, node, target_node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scott/miniforge3/envs/xarray-tutorial/lib/python3.12/site-packages/sphinx_exercise/post_transforms.py", line 143, in resolve_solution_title
    updated_title_text = " " + exercise_title.children[0].astext()
                               ~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/scott/miniforge3/envs/xarray-tutorial/lib/python3.12/site-packages/jupyter_book/sphinx.py", line 167, in build_sphinx
    app.build(force_all, filenames)
  File "/Users/scott/miniforge3/envs/xarray-tutorial/lib/python3.12/site-packages/sphinx/application.py", line 355, in build
    self.builder.build_update()
  File "/Users/scott/miniforge3/envs/xarray-tutorial/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 293, in build_update
    self.build(to_build,
  File "/Users/scott/miniforge3/envs/xarray-tutorial/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 363, in build
    self.write(docnames, list(updated_docnames), method)
  File "/Users/scott/miniforge3/envs/xarray-tutorial/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 571, in write
    self._write_serial(sorted(docnames))
  File "/Users/scott/miniforge3/envs/xarray-tutorial/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 578, in _write_serial
    doctree = self.env.get_and_resolve_doctree(docname, self)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scott/miniforge3/envs/xarray-tutorial/lib/python3.12/site-packages/sphinx/environment/__init__.py", line 635, in get_and_resolve_doctree
    self.apply_post_transforms(doctree, docname)
  File "/Users/scott/miniforge3/envs/xarray-tutorial/lib/python3.12/site-packages/sphinx/environment/__init__.py", line 688, in apply_post_transforms
    transformer.apply_transforms()
  File "/Users/scott/miniforge3/envs/xarray-tutorial/lib/python3.12/site-packages/sphinx/transforms/__init__.py", line 83, in apply_transforms
    super().apply_transforms()
  File "/Users/scott/miniforge3/envs/xarray-tutorial/lib/python3.12/site-packages/docutils/transforms/__init__.py", line 182, in apply_transforms
    transform.apply(**kwargs)
  File "/Users/scott/miniforge3/envs/xarray-tutorial/lib/python3.12/site-packages/sphinx/transforms/post_transforms/__init__.py", line 41, in apply
    self.run(**kwargs)
  File "/Users/scott/miniforge3/envs/xarray-tutorial/lib/python3.12/site-packages/sphinx_exercise/post_transforms.py", line 196, in run
    docname = self.app.builder.current_docname
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'CheckExternalLinksBuilder' object has no attribute 'current_docname'

workaround
pinning sphinx<7 resolves the error, but maybe there is a simple fix to allow for the most recent version?...

Reproduce the bug

Using the following in the _config.yml :

sphinx:
  extra_extensions:
    - sphinx_exercise

jupyter-book build ./ --builder linkcheck

List your environment

Jupyter Book      : 1.0.0
External ToC      : 1.0.1
MyST-Parser       : 2.0.0
MyST-NB           : 1.0.0
Sphinx Book Theme : 1.1.2
Jupyter-Cache     : 1.0.0
NbClient          : 0.8.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant