Failure to find file when building docs

I am trying to build Sphinx documentation for my python project using Github Actions and I am hitting an error stating that the relevant file is not found. The documentation builds fine locally (it works on my machine!). I thought it was might be an issue with location of file but that doesnt seem to be the case as from as the paths in the error hold the correct relative position.

I’ve checked the Sphinx and Github Actions documentation and I havent found anything to indicate what I am doing wrong.

The file structure looks like this:

  • data
    • game
      • traits.json <- the file not found
  • docs
    • _build <- where the docs are being built to
  • scripts
    • engine
      • <- where the error occurs

The error:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/site-packages/sphinx/ext/autodoc/", line 66, in import_module
    return importlib.import_module(modname)
  File "/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/importlib/", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/runner/work/notquiteparadise/notquiteparadise/scripts/engine/", line 26, in <module>
    from scripts.engine.effect import Effect, MoveActorEffect
  File "/home/runner/work/notquiteparadise/notquiteparadise/scripts/engine/", line 9, in <module>
    from scripts.engine import utility, world
  File "/home/runner/work/notquiteparadise/notquiteparadise/scripts/engine/", line 15, in <module>
    from scripts.engine import action, chronicle, debug, library, utility
  File "/home/runner/work/notquiteparadise/notquiteparadise/scripts/engine/", line 8, in <module>
    from scripts.engine import library, world
  File "/home/runner/work/notquiteparadise/notquiteparadise/scripts/engine/", line 228, in <module>
  File "/home/runner/work/notquiteparadise/notquiteparadise/scripts/engine/", line 73, in refresh_library
  File "/home/runner/work/notquiteparadise/notquiteparadise/scripts/engine/", line 111, in _load_traits_data
    with open(DATA_PATH + "game/traits.json") as file:
FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/work/notquiteparadise/notquiteparadise/data/game/traits.json'

The Github Action yaml:

name: NQP - Build Docs

    workflows: ["NQP - Run Tests"]
    branches: [develop, master]
      - completed

    runs-on: ubuntu-latest
      - name: Checkout
        uses: actions/checkout@v2

      - name: Set up Python 3.8
        uses: actions/setup-python@v2
          python-version: 3.8

      - name: Use cache
        uses: actions/cache@v2
          path: ~\AppData\Local\pip\Cache
          key: ${{ runner.os }}-pip-${{ hashFiles('**/poetry.lock') }}
          restore-keys: ${{ runner.os }}-pip-

      - name: Install dependencies
        run: |
          sudo apt-get update
          sudo apt-get install libsdl2-dev
          sudo apt-get install python-sphinx
          python -m pip install --upgrade poetry
          poetry config virtualenvs.create false
          poetry install --no-root

      - name: build-docs
        run: |
          sphinx-apidoc -o ./docs .
          cd docs
          sphinx-build -a -E --keep-going . _build
      - name: deploy-docs
        uses: JamesIves/github-pages-deploy-action@3.5.7
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BRANCH: gh-pages
          FOLDER: docs/_build

Any help would be appeciated!

Your code was referencing a directory that does not exist.

sent you a PR to correct this.


git mv data/Game data/temp

git mv data/temp data/game

git commit -m "Rename folder Game to game"

Hope that’s helpful :v:t4:


Thank you, mate, I have no idea why it was ever Game instead of game!

The PR seems to have fixed that issue (thank you!) but generated a new one. I’ve not seen anything like that before, have you?

ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM default
File "/home/runner/work/notquiteparadise/notquiteparadise/scripts/engine/ui/", line 65, in __init__
    self._window: pygame.display = pygame.display.set_mode((self._desired_width, self._desired_height))
pygame.error: No available video device

If that’s from the Actions build, too, I’d guess it’s tests having issues with the runner VMs not having displays and sound cards. Could you run tests in a headless mode? If not you might need to set up some sort of emulation.

1 Like

I think all the tests are headless but given this is just to build documentation I would have thought it was all headless anyway.

I checked the pygame repo for their CI build and it flags video drivers so perhaps I need to do that, too. They’re using Travis so I need to check if there is anything that wouldn’t apply to Actions.

That depends: As noted in the documentation the call to sphinx-apidoc will import the modules, and side-effects of the imports will be executed. So if, for example, any of your modules tries to initialize display access during import that won’t work headless, similar for audio. The pygame.display.set_mode() call hints at something like that.

If that is indeed the issue the ideal fix would be to change the module so that display and audio initialization is done only when any related code is called.

1 Like

Ah, I am with you. That makes sense and it gives me a clear way forward. Thank you very much. I’ll refactor to avoid those sort of calls and see how it goes.

1 Like

Legend, that did it! Thank you again!

1 Like

Nice, thanks for the update! :smile_cat: