Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileNotFoundError: 'compile_commands.json' in CI #105

Closed
lalten opened this issue Feb 23, 2023 · 3 comments · May be fixed by #193
Closed

FileNotFoundError: 'compile_commands.json' in CI #105

lalten opened this issue Feb 23, 2023 · 3 comments · May be fixed by #193

Comments

@lalten
Copy link

lalten commented Feb 23, 2023

I'm trying to set up the compile_commands.json generation in GitHub Actions CI to feed it to clang-tidy in the next step. But it looks like this line:

with open('compile_commands.json', 'w') as output_file:

fails if the file does not exist yet:

INFO: Running command line: bazel-bin/external/hedron_compile_commands/refresh_all
>>> Automatically added //external workspace link:
    This link makes it easy for you--and for build tooling--to see the external dependencies you bring in. It also makes your source tree have the same directory structure as the build sandbox.
    It's a win/win: It's easier for you to browse the code you use, and it eliminates whole categories of edge cases for build tooling.
>>> Analyzing commands used in @//...
>>> Finished extracting commands for @//...
Traceback (most recent call last):
  File "/github/home/.cache/bazel/_bazel_root/284f8c6ca1cf5fd7f4e20c15176f40/execroot/repo/bazel-out/k8-fastbuild/bin/external/hedron_compile_commands/refresh_all.runfiles/hedron_compile_commands/refresh_all.py", line 1060, in <module>
    with open('compile_commands.json', 'w') as output_file:
FileNotFoundError: [Errno 2] No such file or directory: 'compile_commands.json'
Error: Process completed with exit code 1.
@lalten
Copy link
Author

lalten commented Feb 23, 2023

Never mind, this was an error on my side: compile_commands.json was a symlink to build/compile_commands, which did not exist in CI.

@lalten lalten closed this as completed Feb 23, 2023
@cpsauer
Copy link
Contributor

cpsauer commented Feb 23, 2023

Glad you got through it, and thanks for your interest in using the tool @lalten.

Just for my learning and understanding: What's motivating the symlink?

@lalten
Copy link
Author

lalten commented Feb 24, 2023

It's from a CMake build that we're transitioning away from currently

keith added a commit to keith/bazel-compile-commands-extractor that referenced this issue May 30, 2024
This fix existing as a symlink to a cmake directory seems like a pretty
common use case, and the error when it fails to write is pretty
inscrutable.

Fixes hedronvision#105
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants