<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  <id>https://blog.readthedocs.com</id>
  <title>Read the Docs Blog - Posts by Anthony Johnson</title>
  <updated>2023-07-08T10:50:29.623395+00:00</updated>
  <link href="https://blog.readthedocs.com"/>
  <link href="https://blog.readthedocs.com/archive/author/anthony-johnson/atom.xml" rel="self"/>
  <generator uri="https://ablog.readthedocs.org/" version="0.10.26">ABlog</generator>
  <entry>
    <id>https://blog.readthedocs.com/build-errors-docutils-0-18/</id>
    <title>Build errors with docutils 0.18</title>
    <updated>2021-11-02T00:00:00+00:00</updated>
    <author>
      <name>Anthony Johnson</name>
    </author>
    <content type="html">&lt;section id="build-errors-with-docutils-0-18"&gt;

&lt;p&gt;Starting about a week ago, some users started reporting new errors with
their project builds. In most cases, these errors appeared out of nowhere and
are usually rather cryptic errors referencing &lt;a class="reference external" href="https://pypi.org/project/Sphinx/"&gt;Sphinx&lt;/a&gt; and &lt;a class="reference external" href="https://pypi.org/project/docutils/"&gt;docutils&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;So, what is happening?&lt;/p&gt;
&lt;p&gt;These errors are due to an incompatibility bewteen old versions of &lt;a class="reference external" href="https://pypi.org/project/Sphinx/"&gt;Sphinx&lt;/a&gt; and
one of its dependencies, &lt;a class="reference external" href="https://pypi.org/project/docutils/"&gt;docutils&lt;/a&gt;. You probably have not directly interacted
with docutils, but this is the library that provides reStructuredText parsing to
both Sphinx and to the Python standard library documentation tooling.&lt;/p&gt;
&lt;p&gt;There are a number of errors that users have reported due to this
incompatibility, but the most common error is:&lt;/p&gt;
&lt;div class="highlight-default notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="ne"&gt;TypeError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;generator&amp;#39;&lt;/span&gt; &lt;span class="nb"&gt;object&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;subscriptable&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If your project’s builds suddenly start failing with the above error message, or
other cryptic errors that don’t seem related to your project, your project is
most likely encountering this bug.&lt;/p&gt;
&lt;section id="why-is-this-happening"&gt;
&lt;h2&gt;Why is this happening?&lt;/h2&gt;
&lt;p&gt;The underlying cause for this error is using an outdated version of &lt;a class="reference external" href="https://pypi.org/project/Sphinx/"&gt;Sphinx&lt;/a&gt;
(version &amp;lt; 3.0) with the latest release of &lt;a class="reference external" href="https://pypi.org/project/docutils/"&gt;docutils&lt;/a&gt; (version 0.18,
released October 26). This latest release of docutils is no longer comptible
with Sphinx versions 1.x and 2.x, however these versions do not specify a upper
limit to the version of docutils installed, and so will install the latest
release by default.&lt;/p&gt;
&lt;p&gt;The reason so many projects use an old version of Sphinx
is that, &lt;a class="reference external" href="https://docs.readthedocs.io/en/stable/build-default-versions.html#external-dependencies" title="(in Read the Docs user documentation v9.15.0)"&gt;&lt;span class="xref std std-ref"&gt;before October 2020, Read the Docs had a more strict pinning
policy&lt;/span&gt;&lt;/a&gt;
and Sphinx 1.8 was the default version.
New projects are not affected.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="fixing-the-error"&gt;
&lt;h2&gt;Fixing the error&lt;/h2&gt;
&lt;p&gt;We have proposed to the &lt;a class="reference external" href="https://pypi.org/project/Sphinx/"&gt;Sphinx&lt;/a&gt; and &lt;a class="reference external" href="https://pypi.org/project/docutils/"&gt;docutils&lt;/a&gt; maintainers
&lt;a class="reference external" href="https://github.com/sphinx-doc/sphinx/issues/9807"&gt;a solution that doesn’t involve manual intervention&lt;/a&gt;.
However, for now we suggest you manually
resolve this issue for any of your projects that have encountered the bug.&lt;/p&gt;
&lt;p&gt;There are two ways to resolve this issue:&lt;/p&gt;
&lt;dl&gt;
&lt;dt&gt;Upgrade &lt;a class="reference external" href="https://pypi.org/project/Sphinx/"&gt;Sphinx&lt;/a&gt; to version 3 or later&lt;/dt&gt;&lt;dd&gt;&lt;p&gt;We recommend this option for most users. If your project doesn’t
specifically still require Sphinx 1.x or 2.x, your project can most likely
be upgraded, without issues, to a modern version of Sphinx. As a bonus,
you’ll be able to use the latest Sphinx releases and extensions that only
support modern Sphinx releases.&lt;/p&gt;
&lt;p&gt;It is worth noting that one reason why you might still be using an old
version of Sphinx is if you generate API documentation for Python 2
compatible code. In this case, you’ll have more work ahead of you in order
to upgrade, as Sphinx version 3 and 4 only support Python 3.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;Downgrade &lt;a class="reference external" href="https://pypi.org/project/docutils/"&gt;docutils&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;p&gt;This is the next best option if you can’t immediately upgrade Sphinx. If you
are familiar with Python packaging, the best specifier to use is
&lt;code class="docutils literal notranslate"&gt;&lt;span class="pre"&gt;docutils&amp;lt;0.18&lt;/span&gt;&lt;/code&gt;.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;/section&gt;
&lt;section id="fixing-the-error-on-read-the-docs"&gt;
&lt;h2&gt;Fixing the error on Read the Docs&lt;/h2&gt;
&lt;p&gt;If you aren’t already, you should add a &lt;a class="reference external" href="https://docs.readthedocs.io/en/stable/config-file/v2.html" title="(in Read the Docs user documentation v9.15.0)"&gt;&lt;span class="xref std std-doc"&gt;configuration file&lt;/span&gt;&lt;/a&gt;
for your project, so that you can specify additional dependencies to install at
build time. There are a few supported methods for installation, depending on how
you normally install dependencies for your project. If you are not currently
specifying any dependencies on Read the Docs, you most likely will want to use
the &lt;a class="reference external" href="https://docs.readthedocs.io/en/stable/config-file/v2.html#requirements-file" title="(in Read the Docs user documentation v9.15.0)"&gt;&lt;span class="xref std std-ref"&gt;python.install.requirements&lt;/span&gt;&lt;/a&gt; configuration option.&lt;/p&gt;
&lt;p&gt;This is how the reference &lt;code class="docutils literal notranslate"&gt;&lt;span class="pre"&gt;.readthedocs.yaml&lt;/span&gt;&lt;/code&gt; and &lt;code class="docutils literal notranslate"&gt;&lt;span class="pre"&gt;docs/requirements.txt&lt;/span&gt;&lt;/code&gt; files
would look like:&lt;/p&gt;
&lt;div class="literal-block-wrapper docutils container" id="id1"&gt;
&lt;div class="code-block-caption"&gt;&lt;span class="caption-text"&gt;.readthedocs.yaml&lt;/span&gt;&lt;/div&gt;
&lt;div class="highlight-yaml notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nt"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;2&lt;/span&gt;

&lt;span class="nt"&gt;python&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;install&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;requirements&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;docs/requirements.txt&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="literal-block-wrapper docutils container" id="id2"&gt;
&lt;div class="code-block-caption"&gt;&lt;span class="caption-text"&gt;docs/requirements.txt&lt;/span&gt;&lt;/div&gt;
&lt;div class="highlight-default notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;docutils&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mf"&gt;0.18&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you still experience problems, feel free to
&lt;a class="reference external" href="https://github.com/readthedocs/readthedocs.org/issues/"&gt;open an issue&lt;/a&gt;.&lt;/p&gt;
&lt;div class="admonition seealso"&gt;
&lt;p class="admonition-title"&gt;See also&lt;/p&gt;
&lt;dl class="simple"&gt;
&lt;dt&gt;&lt;a class="reference external" href="https://docs.readthedocs.io/en/stable/guides/setup/configuration-file.html" title="(in Read the Docs user documentation v9.15.0)"&gt;&lt;span&gt;How to add a configuration file&lt;/span&gt;&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;p&gt;An introduction to our configuration file and some basic usage examples&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;a class="reference external" href="https://docs.readthedocs.io/en/stable/config-file/v2.html#python-install" title="(in Read the Docs user documentation v9.15.0)"&gt;&lt;span class="xref std std-ref"&gt;.readthedocs.yaml python.install options&lt;/span&gt;&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;p&gt;All of the supported Python dependency installation options&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;a class="reference external" href="https://github.com/readthedocs/readthedocs.org/issues/8616"&gt;https://github.com/readthedocs/readthedocs.org/issues/8616&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;p&gt;An example stack trace of this bug and discussion around resolving the
error&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;/div&gt;
&lt;/section&gt;
&lt;/section&gt;
</content>
    <link href="https://blog.readthedocs.com/build-errors-docutils-0-18/" rel="alternate"/>
    <summary>Starting about a week ago, some users started reporting new errors with
their project builds. In most cases, these errors appeared out of nowhere and
are usually rather cryptic errors referencing Sphinx and docutils.So, what is happening?</summary>
    <category term="builders" label="builders"/>
    <published>2021-11-02T00:00:00+00:00</published>
  </entry>
</feed>
