Readthedocs.org: Build Failing with ``AttributeError: 'NoneType' object has no attribute 'traverse'``

Created on 1 Sep 2016  路  24Comments  路  Source: readthedocs/readthedocs.org

Details

_A description of what you wanted to happen_
Successful docs build

Actual Result

_A description of what actually happened_
Build errors with AttributeError: 'NoneType' object has no attribute 'traverse'

Sphinx versions tried:

1.4.5, 1.4.6

Summary

The build fails with the traceback shown below.

Honestly, I'm not sure if this is a sphinx issue or an rtd issue, but it doesn't happen when I build the docs locally.

I'm not sure why it's trying to assemble a single document, because this project is not configured to be built as single page html.

Traceback:

Running Sphinx v1.4.5
making output directory...
loading translations [en]... done
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [readthedocssinglehtmllocalmedia]: all documents
updating environment: 8 added, 0 changed, 0 removed
reading sources... [ 12%] README
reading sources... [ 25%] docs/includes/examples/README
reading sources... [ 37%] docs/includes/examples/concept_what-is-guacamole
reading sources... [ 50%] docs/includes/examples/concept_what-is-salsa
reading sources... [ 62%] docs/includes/examples/ref_ingredients-guac
reading sources... [ 75%] docs/includes/examples/ref_ingredients-salsa
reading sources... [ 87%] docs/includes/examples/topic_make-guacamole
reading sources... [100%] docs/includes/examples/topic_make-salsa

/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/checkouts/latest/docs/includes/examples/ref_ingredients-salsa.rst:5: WARNING: duplicate label ingredients, other instance in /home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/checkouts/latest/docs/includes/examples/ref_ingredients-guac.rst
/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/checkouts/latest/docs/includes/examples/topic_make-salsa.rst:5: WARNING: duplicate label steps, other instance in /home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/checkouts/latest/docs/includes/examples/topic_make-guacamole.rst
looking for now-outdated files... none found
pickling environment... done
checking consistency... /home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/checkouts/latest/docs/includes/examples/README.rst:: WARNING: document isn't included in any toctree
done
preparing documents... done
assembling single document... 
writing... 
Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/sphinx/cmdline.py", line 244, in main
    app.build(opts.force_all, filenames)
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/sphinx/application.py", line 297, in build
    self.builder.build_update()
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 246, in build_update
    self.build(['__all__'], to_build)
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 322, in build
    self.write(docnames, list(updated_docnames), method)
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/sphinx/builders/html.py", line 1023, in write
    self.write_doc(self.config.master_doc, doctree)
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/sphinx/builders/html.py", line 452, in write_doc
    self.handle_page(docname, ctx, event_arg=doctree)
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/sphinx/builders/html.py", line 803, in handle_page
    output = self.templates.render(templatename, ctx)
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/readthedocs_ext/readthedocs.py", line 101, in rtd_render
    content = old_render(template, render_context)
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/sphinx/jinja2glue.py", line 138, in render
    return self.environment.get_template(template).render(context)
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/sphinx/themes/basic/page.html", line 10, in top-level template code
    {%- extends "layout.html" %}
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/sphinx_rtd_theme/layout.html", line 122, in top-level template code
    {% block menu %}
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/sphinx_rtd_theme/layout.html", line 123, in block "menu"
    {% set toctree = toctree(maxdepth=4, collapse=theme_collapse_navigation, includehidden=True) %}
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/jinja2/sandbox.py", line 355, in call
    return __context.call(__obj, *args, **kwargs)
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/sphinx/builders/html.py", line 793, in <lambda>
    ctx['toctree'] = lambda **kw: self._get_local_toctree(pagename, **kw)
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/sphinx/builders/html.py", line 955, in _get_local_toctree
    self.fix_refuris(toctree)
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/sphinx/builders/html.py", line 940, in fix_refuris
    for refnode in tree.traverse(nodes.reference):
AttributeError: 'NoneType' object has no attribute 'traverse'

Exception occurred:
  File "/home/docs/checkouts/readthedocs.org/user_builds/f5-docs-training/envs/latest/local/lib/python2.7/site-packages/sphinx/builders/html.py", line 940, in fix_refuris
    for refnode in tree.traverse(nodes.reference):
AttributeError: 'NoneType' object has no attribute 'traverse'
The full traceback has been saved in /tmp/sphinx-err-xO2X99.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
more information replication

Most helpful comment

@da4089 Same, I'm seeing this same error on Read the Docs. Locally, using Sphinx (1.6.4) build works, but I'm getting this error on RTD, which uses sphinx version 1.5.3.

To require RTD to use sphinx >= 1.6.0, I used a yaml file and a requirements.txt as seen in this commit: https://github.com/NCBI-Hackathons/Tumor_sim/commit/4c28466329a31e8020f659ac77b42f065209d918 . This resolved the error.

All 24 comments

I have the same issue here. It seems that you got the project to build eventually. What was the workaround?

+1

I'm experiencing the same thing. I'm curious how you solved it. Would be great if you can share your workaround?

I don't recall exactly what the workaround was, apologies for not posting it here when it actually happened! I believe this had to do with toctrees, though. If you have any toctrees that are referencing 'self', try taking that out and rebuilding. Also, if you're using 1.4.5/6 like I was, try upgrading.

I ran into this problem and I think it was happening because I had a requirements-dev.txt file in my repository with the following in it:

Sphinx==1.5.2
sphinx-autobuild==0.6.0
sphinx-rtd-theme==0.1.9

I also pointed to this file under the Requirements file field of the Advanced Settings pane of the Admin area.

With this setup, however, I was getting a traceback similar to the one in the description of this issue.

But once I removed the reference to requirements-dev.txt in the admin UI, everything seemed to work okay!

Additionally, I followed the instructions for using this theme locally, then building on Read the Docs for the sphinx-rtd-theme, but I don't think that had anything to do with getting this particular traceback (I could be wrong though).

Hmm, I'm not sure if this is related, but given that the exception seems to be coming from rendering the table of contents tree, I thought it might be.

Basically, in local development, I'm getting a full auto-generated TOC, but on RTD I'm getting an empty TOC (screenshots are at https://github.com/18F/cg-django-uaa/issues/9). I think this may have something to do with RTD using Sphinx v1.3.5, while my local development setup is using v1.5.2.

I believe i've pinpointed this. It's an issue stemming from our theme. I've put up snide/sphinx_rtd_theme#367 to address this, i'll get a release out on the theme after.

This fix wasn't correct.

This is caused by an empty toctree in your project. It's a Sphinx bug, but by not having an empty TOC Tree, it should be fixed.

An empty TOC tree can easily happen when using Markdown instead of RST. I use a single README.md as master_doc in conf.py:

~python
from recommonmark.parser import CommonMarkParser
source_parsers = { '.md': CommonMarkParser }
source_suffix = '.md'
master_doc = 'README'
~

Builds at RTD fail with the error message given above, but output HTML is still being generated as visible in this project: https://readthedocs.org/projects/wdtaxonomy/builds/

I am not familiar with Sphinx internals, maybe the error can be fixed by extending Sphinx to use a default toctree from master_doc if the latter does not contain a TOC Tree?

I've opened up a proper fix with Sphinx: sphinx-doc/sphinx#3518

I also opened up a temporary patch to our theme: snide/sphinx_rtd_theme#373

Huzzah! I released (several) versions of our theme today. The latest release seems to resolve this issue. @nichtich i tested against your repo, anyone else having trouble with this still after a fresh build?

Going to close this, as I believe it should be fixed.

I'm still receiving this error. This is my first time using RTD, but as was described earlier, I'm able to build with Sphinx locally, but RTD throws the
AttributeError: 'NoneType' object has no attribute 'traverse'
You can see all my docs files here.
I've tried to go as bare bones as possible and I continue to get that error on RTD.

+1, build fails with
AttributeError: 'NoneType' object has no attribute 'traverse'
message.

My docs are here.
One of failed builds here (not sure if you have access to it).

Please, help to find workaround for this issue.

I'm also having this problem. My docs contain nothing but the generated result of sphinx-quickstart with everything set to default.
Failed build: https://readthedocs.org/projects/tid/builds/5903374/

any updates? I'm seeing this also

I'm seeing it too. Used sphinx-quickstart-1.6.3 to generate a skeleton doc. Local build of HTML works; RTD reports this error.

This is a problem with Sphinx < 1.6. We need to update our default version. You can pin your requirements on RTD until then.

@da4089 Same, I'm seeing this same error on Read the Docs. Locally, using Sphinx (1.6.4) build works, but I'm getting this error on RTD, which uses sphinx version 1.5.3.

To require RTD to use sphinx >= 1.6.0, I used a yaml file and a requirements.txt as seen in this commit: https://github.com/NCBI-Hackathons/Tumor_sim/commit/4c28466329a31e8020f659ac77b42f065209d918 . This resolved the error.

As someone who isn't terribly well versed in Python and Sphinx, is there an immediate resolution to this other than downgrading my local Sphinx install and starting again?

This is a problem with Sphinx < 1.6. We need to update our default version. You can pin your requirements on RTD until then.
@agjohnson can you please elaborate?

@liiight you need to create a requirements.txt file in your project with sphinx >= 1.6 and go to the admin section of your rtd project, there you can specify using it.

I'm closing this since looks like it's already solved, the users need to update the sphinx version only.

Was this page helpful?
0 / 5 - 0 ratings