Sarcasm / compdb

The compilation database Swiss army knife
MIT License
292 stars 23 forks source link

Error while adding headers #26

Open BSB47 opened 2 years ago

BSB47 commented 2 years ago

Hi, I'm getting an error while using compdb -p ./ list > compile_commands.json:

File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

causing compdb to end with code 1. Any idea what is causing this? Thank you

afrischk commented 2 years ago

Same for me.

AquaVirus commented 2 years ago

That happens because compile_commands.json gets modified while compdb is reading from it. You can get around this issue by writing to a temporary file first, e.g:

compdb -p ./ list > temp && mv temp compile_commands.json

Or by using some other method to ensure the command finishes before writing to the compile_commands.json file.