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

clang-tidy is not found when installed in a custom path #19

Closed
aminya opened this issue May 5, 2022 · 8 comments · Fixed by #27
Closed

clang-tidy is not found when installed in a custom path #19

aminya opened this issue May 5, 2022 · 8 comments · Fixed by #27

Comments

@aminya
Copy link

aminya commented May 5, 2022

clang-tidy is not found in run_clang_tidy.sh although it is on the PATH. It seems that the spawn doesn't pass the env variables.

@erenon
Copy link
Owner

erenon commented May 6, 2022

Do you have --action_env specified?

@aminya
Copy link
Author

aminya commented May 6, 2022

No, as far as I have set. Maybe my dependencies set that. I can check and get back to you

@aminya
Copy link
Author

aminya commented May 6, 2022

I checked. I didn't specify that. I hope it can be fixed.

I have found a hacky workaround to hot patch the clang_tidy path using go-task

  clang_tidy_path:
    cmds:
      - sed -i '/^clang-tidy "\$@"$/s|clang-tidy|{{.HOME}}/llvm/bin/clang-tidy -p {{.CWD}}|' {{.run_clang_tidy}}
    preconditions:
      - test -f {{.run_clang_tidy}}
    vars:
      run_clang_tidy: ./external/bazel_clang_tidy/clang_tidy/run_clang_tidy.sh
      CWD:
        sh: git rev-parse --show-toplevel

  clang_tidy:
    cmds:
      - task: clang_tidy_path
      - bazel build --config=tidy myproj

I run [compile_commands.json] extractor before running clang_tidy:
https://github.com/hedronvision/bazel-compile-commands-extractor

@erenon
Copy link
Owner

erenon commented May 6, 2022 via email

@aminya
Copy link
Author

aminya commented May 6, 2022

My PATH variable is already set. What should I specify in action_env? I cannot find anything in the documentation.

@erenon
Copy link
Owner

erenon commented May 9, 2022

Here's the doc: https://docs.bazel.build/versions/main/command-line-reference.html#flag--action_env
action_env should specify a path set that contains your custom clang tidy install.

@oliverlee
Copy link
Contributor

If you are on macOS, see bazelbuild/bazel#12049

@kkpattern
Copy link

We created a llvm_repo repository rule to create an external repository and link the installed llvm directory into the llvm_repo. This ensures bazel_clang_tidy can find clang-tidy and also makes the clang-tidy check reproducible.

Here is the related blog if anyone is interested.

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.

4 participants