VersionConflict in Read the Docs build images when project specifies newer Sphinx than image provides
0 reputation · 20 Nov 2020, 08:27 UTC
0 reputation · 20 Nov 2020, 08:27 UTC
When a project declares sphinx==7.2.6 in requirements.txt while the build image readthedocs/build:22.04 provides sphinx 6.2.1, the build may emit VersionConflict: (sphinx==6.2.1, Requirement.parse("sphinx>=7.2.6"))
The precise goal is to determine which Sphinx version is installed and used first during the build setup, and whether the precedence is deterministic given the documented configuration options.
Which Sphinx version is installed first during the build setup? Does the .readthedocs.yaml build.image setting affect precedence, or is the system‑installed Sphinx always preferred? Is there a documented way to enforce a specific Sphinx version without custom Docker images?
35275 reputation · 20 Nov 2020, 10:06 UTC
During a standard Read the Docs build the install phase creates a Python virtual environment, then runs pip install -r requirements.txt. The Sphinx version declared in requirements.txt (or the latest available if none) is installed inside that virtualenv, and the sphinx-build command that runs later uses the sphinx executable from that environment. Therefore the version installed first is the one from the virtualenv, not the system‑installed package.
The system‑installed Sphinx from the base image is used only if the build skips the virtualenv step (e.g., the no virtualenv flag or a custom Dockerfile that runs pip install directly on the host filesystem). In that case the sphinx-build binary from the image’s /usr/bin is executed before any pip‑installed version.
The build.image directive selects the Docker base image (OS packages and default Python version) but does not change the order in which Sphinx is invoked. The precedence remains: virtualenv‑installed Sphinx first, then system‑installed Sphinx if the virtualenv step is omitted.
requirements.txt, for example sphinx==7.2.6.NO_VIRTUALENV or a custom Dockerfile that bypasses pip install -r requirements.txt).pip install -r requirements.txt and confirming the reported version with pip show sphinx or sphinx-build --version.pip install -r requirements.txt and note the Sphinx version reported by pip show sphinx.sphinx-build runs inside an activated virtualenv by looking for VIRTUAL_ENV in the logs or by adding which sphinx-build before the build step.Do you use a custom Dockerfile that skips the virtualenv step (e.g., runs pip install directly or sets NO_VIRTUALENV)? This information determines whether the system‑installed Sphinx could be used first.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.