{"record":{"id":"4db9c15b28abb494","repo":"NationalSecurityAgency/ghidra","slug":"could-not-parse-pyproject-toml","errorCode":null,"errorMessage":"Could not parse pyproject.toml","messagePattern":"Could not parse pyproject\\.toml","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-rmi-trace/src/main/py/src/ghidratrace/setuputils.py","lineNumber":65,"sourceCode":"def get_module_dependencies(name: str) -> List[str]:\n    src = ghidra_module_src(name)\n    # Can't rely on tomllib until Python 3.11 is minimum requirement.\n    # And, I'm in a place where I presume deps are missing, so do this garbage\n    # of a parse job.\n    with open(f\"{src}/pyproject.toml\") as project:\n        seen_deps = False\n        result: List[str] = []\n        for l in project.readlines():\n            l = l.strip()\n            if l == \"dependencies = [\":\n                seen_deps = True\n            elif seen_deps and l == ']':\n                return [r for r in result if not 'ghidra' in r]\n            elif seen_deps:\n                if l.endswith(','):  # Last one may not have ,\n                    l = l[:-1].strip()\n                result.append(l[1:-1])  # Remove 's or \"s\n        raise Exception(\"Could not parse pyproject.toml\")\n\n\ndef prompt_mitigation(msg: str, prompt: str) -> bool:\n    print(\"\"\"\n--------------------------------------------------------------------------------\n!!!                       INCORRECT OR INCOMPLETE SETUP                      !!!\n--------------------------------------------------------------------------------\n\"\"\")\n    print(msg)\n    print(\"\")\n    print(\"Select KEEP if you're seeing this in an error dialog.\")\n    print(f\"{prompt} [Y/n] \", end=\"\")\n    answer = input()\n    return answer == 'y' or answer == 'Y' or answer == ''\n\n\ndef mitigate_by_pip_install(*args: str) -> None:\n    import sys","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-rmi-trace/src/main/py/src/ghidratrace/setuputils.py#L47-L83","documentation":"Raised as a generic Exception by get_module_dependencies() when its hand-rolled line-by-line parser cannot find a 'dependencies = [' ... ']' block in the module's pyproject.toml. The parser expects the literal line 'dependencies = [' followed by quoted entries and a closing ']'; any deviation (different formatting, TOML table structure, missing block) causes a fall-through to this error.","triggerScenarios":"A pyproject.toml that lists deps under a different key, uses inline arrays ([pkg, pkg]), lacks a dependencies block, or was reformatted (e.g. by a TOML formatter that changes quoting/spaces).","commonSituations":"Editing pyproject.toml and reformatting it; module whose toml genuinely has no dependencies block; tooling that rewrote the array onto one line.","solutions":["Restore the literal multi-line 'dependencies = [' block with one quoted entry per line in the module's pyproject.toml.","Ensure the block has at least the opening and closing lines exactly as the parser expects.","Avoid reformatting ghidra module pyproject.toml files with generic TOML formatters."],"exampleFix":"# before (in pyproject.toml)\ndependencies = [\"a\", \"b\"]\n# after\ndependencies = [\n    \"a\",\n    \"b\",\n]","handlingStrategy":"try-catch","validationCode":"with open(pyproject) as f:\n    lines = [l.strip() for l in f]\nassert 'dependencies = [' in lines, 'pyproject.toml missing dependencies block'","typeGuard":null,"tryCatchPattern":"try:\n    deps = get_module_dependencies(name)\nexcept Exception:\n    # restore the literal dependencies block, then retry\n    raise","preventionTips":["Keep ghidra module pyproject.toml in the expected multi-line format.","Avoid generic TOML reformatting on these files."],"tags":["setup","configuration","trace-rmi","parsing"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}