GitHub推送触发Read The Docs自动构建失败,无明显报错
Read The Docs自动构建异常:Git操作完成后无构建命令直接失败
原本通过GitHub Webhook触发的Read The Docs自动构建此前运行正常,今日突然失效,无明显错误提示。构建日志显示,所有Git相关操作(克隆、拉取、切换分支、清理)均成功执行,但后续未触发任何构建命令就标记构建失败。
仓库:kammetherell/py4pa
构建日志
Read the Docs build information Build id: 23541682 Project: py4pa Version: latest Commit: None Date: 2024-02-23T16:04:42.332307Z State: finished Success: False [rtd-command-info] start-time: 2024-02-23T16:04:42.934047Z, end-time: 2024-02-23T16:04:43.259609Z, duration: 0, exit-code: 0 git clone --depth 1 https://github.com/kammetherell/py4pa.git . Cloning into '.'... [rtd-command-info] start-time: 2024-02-23T16:04:43.280323Z, end-time: 2024-02-23T16:04:43.799255Z, duration: 0, exit-code: 0 git fetch origin --force --prune --prune-tags --depth 50 refs/heads/release:refs/remotes/origin/release From https://github.com/kammetherell/py4pa * [new tag] 0.0.3 -> 0.0.3 * [new tag] 0.0.4 -> 0.0.4 * [new tag] 0.0.5 -> 0.0.5 [rtd-command-info] start-time: 2024-02-23T16:04:43.910368Z, end-time: 2024-02-23T16:04:43.973770Z, duration: 0, exit-code: 0 git checkout --force origin/release Note: switching to 'origin/release'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by switching back to a branch. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -c with the switch command. Example: git switch -c <new-branch-name> Or undo this operation with: git switch - Turn off this advice by setting config variable advice.detachedHead to false HEAD is now at 62a9c8f switch to pyproject.toml [rtd-command-info] start-time: 2024-02-23T16:04:43.999721Z, end-time: 2024-02-23T16:04:44.060829Z, duration: 0, exit-code: 0 git clean -d -f -f
readthedocs.yaml配置
# .readthedocs.yaml # Read the Docs configuration file # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details # Required version: 2 # Set the version of Python and other tools you might need build: os: ubuntu-lts-latest tools: python: "3.9" # Build documentation in the docs/ directory with Sphinx sphinx: configuration: docs/source/conf.py # If using Sphinx, optionally build your docs in additional formats such as PDF # formats: # - pdf # Optionally declare the Python requirements required to build your docs python: install: - method: pip path: . system_packages: true
排查与解决步骤
1. 检查配置文件有效性
- 确认
.readthedocs.yaml在仓库根目录,文件名无拼写或大小写错误(YAML对格式敏感)。 - 用Read The Docs项目设置里的配置验证工具,检查语法是否合规,重点排查缩进错误。
2. 验证文档目录结构
- 确认
docs/source/conf.py路径正确且文件存在,RTD找不到Sphinx配置文件会直接终止构建。 - 检查
docs目录下的源文件(.rst/.md)是否完整,未被误删或移动。
3. 排查依赖安装问题
- 当前配置用
pip install .安装项目,若pyproject.toml/setup.py存在问题,可能导致依赖安装失败但日志未显示完整错误。 - 本地模拟RTD构建环境测试:
查看是否有报错,定位依赖或文档构建问题。python3.9 -m venv rtd-env source rtd-env/bin/activate pip install . cd docs/source sphinx-build -b html . _build/html
4. 检查RTD项目设置
- 确认项目版本设置中,
latest关联的是正确的release分支。 - 检查GitHub Webhook是否正常发送请求,RTD是否接收成功(可在构建历史查看触发来源)。
- 手动触发一次构建,排除Webhook临时故障。
5. 获取完整构建日志
- 当前日志仅显示Git操作步骤,后续错误可能被截断。在RTD构建页面展开“详细日志”或查看原始日志,确认是否有隐藏的报错信息(如依赖安装失败、Sphinx配置错误等)。
内容的提问来源于stack exchange,提问作者KevinD
相关产品推荐
相关产品推荐

