Skip to content

clang.cindex.TranslationUnitLoadError: Error parsing translation unit #28

Open

Description

@nyckmaia

Hi, I'm trying to run the pybind11_mkdoc in a single file called score.h, but I got this error below:

C:\Users\nyck\Desktop\maialib>python -m pybind11_mkdoc maiacore\include\maiacore\score.h
Processing "'maiacore\include\maiacore\score.h'" ..
Waiting for jobs to finish ..
error: error reading ''maiacore\include\maiacore\score.h''
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\Users\nyck\AppData\Roaming\Python\Python310\site-packages\pybind11_mkdoc\mkdoc_lib.py", line 246, in run
    tu = index.parse(self.filename, self.parameters)
  File "C:\Users\nyck\AppData\Roaming\Python\Python310\site-packages\clang\cindex.py", line 2722, in parse
    return TranslationUnit.from_source(path, args, unsaved_files, options,
  File "C:\Users\nyck\AppData\Roaming\Python\Python310\site-packages\clang\cindex.py", line 2837, in from_source
    raise TranslationUnitLoadError("Error parsing translation unit.")
clang.cindex.TranslationUnitLoadError: Error parsing translation unit.

The file score.h is a valid C++ header that contains a valid Doxygen documentation in it.

Please, could you help me?

My system:

  • Windows 10 x64
  • Clang LLVM 15.0.6 installed
  • Python 3.10
  • pybind11_mkdoc-2.6.2.dev1 (filename=pybind11_mkdoc-2.6.2.dev1-py3-none-any.whl)

Activity

  1. leakec commented on Nov 15, 2025

    @leakec
    Collaborator

    @nyckmaia I'm going through old issues and trying to close them out. Are you able to share the score.h file that you were having trouble with? It will be hard to help if I can't reproduce the error.

  2. nyckmaia commented on Nov 17, 2025

    @nyckmaia
    Author

    Hi @leakec ,

    I'm not currently using pybind11_mkdoc. When I made that post, I was just testing the tool and seeing if it could easily integrate with my maialib project.

    Unfortunately, I don't have time to continue testing, but I'll leave the link to the code in my score.h file on GitHub here, okay?

    https://github.com/nyckmaia/maialib/blob/main/maiacore/include/maiacore/score.h

  3. leakec commented on Nov 17, 2025

    @leakec
    Collaborator

    Hi @leakec ,

    I'm not currently using pybind11_mkdoc. When I made that post, I was just testing the tool and seeing if it could easily integrate with my maialib project.

    Unfortunately, I don't have time to continue testing, but I'll leave the link to the code in my score.h file on GitHub here, okay?

    https://github.com/nyckmaia/maialib/blob/main/maiacore/include/maiacore/score.h

    @nyckmaia That's perfect, thank you! I'm pretty busy the next couple of weeks, but hoping to test it out afterward and see if I can re-create (and then hopefully fix) the issue.

  4. leakec commented on Nov 30, 2025

    @leakec
    Collaborator

    Unfortunatley, I do not have acccess to a Windows 10 machine, so reproducing will likely be difficult. I did run this in a clean Ubuntu docker image using:

    FROM ubuntu:24.04
    
    # Update package lists and install sudo
    RUN apt update
    RUN apt install -y sudo python3-dev python3-pip git llvm clang

    I then set up a Python virtual environment for 3.10 and installed the following:

    uv pip install git+https://github.com/pybind/pybind11_mkdoc.git@master
    uv pip install clang==18.*
    

    and from maialib/maiacore/include I ran

    python -m pybind11_mkdoc -I. -I../external/sqlitecpp/include -Iexternal/cpptrace/include -Iexternal -std=c++17 -o do
    cs.h maiacore/score.h

    This produces a docs.h file with no errors that looks like it contains all the intended docstrings. My hunch is that the translational unit parsing error comes either from the clang version used (the Ubuntu container has 18, while 15 was used when the error was reported) or this is an issue with Windows which is not explicitly supported.

    I'll leave this issue open. Maybe someone else who has access to a Windows 10 machine can test this with the LLVM version specified and see if they can reproduce the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions