question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

“'myst' reference target not found: b.md#anchor” when building in parallel

See original GitHub issue

Describe the problem

I configured myst_heading_anchors = 2 as documented, but anchor links are giving me this warning if I enable parallelism (sphinx-build -W -j N for any N other than 1):

Warning, treated as error:
/tmp/myst-anchor-test/docs/dir/a.md:2:'myst' reference target not found: b.md#anchor

When building without parallelism, there is no warning and the anchor works fine.

Link to your repository or website

https://github.com/andersk/myst-anchor-test

Steps to reproduce

$ pip install Sphinx myst-parser
…
Successfully installed Jinja2-3.0.1 MarkupSafe-2.0.1 Pygments-2.9.0 Sphinx-4.1.2 alabaster-0.7.12 attrs-21.2.0 babel-2.9.1 certifi-2021.5.30 charset-normalizer-2.0.4 docutils-0.17.1 idna-3.2 imagesize-1.2.0 markdown-it-py-1.1.0 mdit-py-plugins-0.2.8 myst-parser-0.15.1 packaging-21.0 pyparsing-2.4.7 pytz-2021.1 pyyaml-5.4.1 requests-2.26.0 snowballstemmer-2.1.0 sphinxcontrib-applehelp-1.0.2 sphinxcontrib-devhelp-1.0.2 sphinxcontrib-htmlhelp-2.0.0 sphinxcontrib-jsmath-1.0.1 sphinxcontrib-qthelp-1.0.3 sphinxcontrib-serializinghtml-1.1.5 urllib3-1.26.6
$ git clone https://github.com/andersk/myst-anchor-test.git
$ cd myst-anchor-test
$ sphinx-build -W -j2 docs build
Running Sphinx v4.1.2
…
Warning, treated as error:
/tmp/myst-anchor-test/docs/dir/a.md:2:'myst' reference target not found: b.md#anchor
$ sphinx-build -W docs build
Running Sphinx v4.1.2
build succeeded.

The HTML pages are in build.

If you want to reproduce again, rm -rf build.

The version of Python you’re using

3.9.6

Your operating system

NixOS 21.11

Versions of your packages

$ pip freeze
alabaster==0.7.12
attrs==21.2.0
Babel==2.9.1
certifi==2021.5.30
charset-normalizer==2.0.4
docutils==0.17.1
idna==3.2
imagesize==1.2.0
Jinja2==3.0.1
markdown-it-py==1.1.0
MarkupSafe==2.0.1
mdit-py-plugins==0.2.8
myst-parser==0.15.1
packaging==21.0
Pygments==2.9.0
pyparsing==2.4.7
pytz==2021.1
PyYAML==5.4.1
requests==2.26.0
snowballstemmer==2.1.0
Sphinx==4.1.2
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
urllib3==1.26.6

Additional context

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
chrisjsewellcommented, Feb 23, 2022

Its okay, I know why it is, fixing now

0reactions
anderskcommented, Feb 23, 2022

Indeed, removing the myst_anchors test seems to fix the problem completely:

--- a/myst_parser/myst_refs.py
+++ b/myst_parser/myst_refs.py
@@ -203,7 +203,7 @@ class MystReferenceResolver(ReferencesResolver):
     ) -> Optional[Element]:
         """Resolve doc with anchor."""
         target = node["reftarget"]  # type: str
-        if not ("#" in target and hasattr(self.env, "myst_anchors")):
+        if "#" not in target:
             return None
         # the link may be a heading anchor; we need to first get the relative path
         rel_path, anchor = target.rsplit("#", 1)
Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found