Skip to content

Warning treated as error with -W invalidates the entire incremental build cache #10416

@vpoughonEZ

Description

@vpoughonEZ

Describe the bug

Using -W means that a build following a build with an error will not be incremental.

How to Reproduce

Step 0: Setup a simple sphinx project with three files:

index.rst:

Title
=====

.. toctree::

   file1.rst
   file2.rst

file1.rst:

File 1
======

This is file1.

file2.rst:

File 2
======

This is file2.
  • Step 1 Build the project with sphinx-build -b html source/ output/ -W -N
  • Step 2 Add an undefined reference in file1.rst, for example, modify it as such:
File 1
======

This is file1.

:ref:`invalidref`

As expected, we get a warning treated as error:

Warning, treated as error:
/home/vpoughon/ez/tuto-sphinx/source/file1.rst:6:undefined label: invalidref
  • Step 3 Fix the warning (remove the undefined reference) and rebuild with the same command: sphinx-build -b html source/ output/ -W -N

Observed behavior: Sphinx rebuilds all files (including file2.rst) and the build is not incremental:

reading sources... [ 33%] file1
reading sources... [ 66%] file2
reading sources... [100%] index

looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [ 33%] file1
writing output... [ 66%] file2
writing output... [100%] index

Expected behavior

In Step 3 above, file2.rst is not rebuilt.

Your project

See above

Screenshots

No response

OS

Fedora 33

Python version

3.9.9

Sphinx version

4.2.0

Sphinx extensions

none

Extra tools

No response

Additional context

Note that using --keep-going does not solve my use case, because using it can hide errors on subsequent builds. i.e. if I use --keep-going and build a project with an invalid reference twice, the second build will not show any error.

I would like to use -W only, and keep all builds incremental even across builds with errors.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions