PlatformIO Community

Clang Tidy: error on Arch Linux -


Today I want to analyze my codebase using clangtidy. I’ve setup simple configuration for my env:

check_tool = clangtidy
check_severity = low, medium, high
check_flags =
    clangtidy: --checks=-*,bugprone-*,cppcoreguidelines-*,clang-analyzer-*,hicpp-*,modernize-*,performance-*,readability-*

And unfortunately, it always give me this output from my pio check command:

Checking nodemcuv2 > clangtidy (platform: espressif8266; board: nodemcuv2; framework: arduino)

Error: Failed to execute check command! Exited with code 127.
Error: clangtidy failed to perform check! Please examine tool output in verbose mode.
============================================================== [FAILED] Took 0.01 seconds ==============================================================

Environment    Tool       Status    Duration
-------------  ---------  --------  ------------
nodemcuv2      clangtidy  FAILED    00:00:00.012

This problem let me check directly to the clang-tidy binary that PlatformIO bring on my ~/.platformio/packages/tool-clangtidy/clang-tidy.

At least i want to call it directly to check the version or so ./clang-tidy --version and this is what i got:

./clang-tidy: error while loading shared libraries: cannot open shared object file: No such file or directory

I have no clue what’s going on here, I don’t want to mess around with my system (looking for that one shared library) for now. My system’s clang-tidy is just working fine. So my solution was to let the PlatformIO using my own clang-tidy.


Create a link from my clang-tidy binary to PlatformIO tool-clangtidy folder.

  1. Backup the error binary first
$ mv clang-tidy clang-tidy_pio-error
  1. Create a link from system’s clang-tidy executable file to current directory (~/.platformio/packages/tool-clangtidy/clang-tidy)
$ ln -sf /usr/bin/clang-tidy ./clang-tidy

And now pio check should be fine!

Additional resources

  • my package.json file: pastebin
  • my system’s clang-tidy --version:
  LLVM version 11.0.1
  Optimized build.
  Default target: x86_64-pc-linux-gnu
  Host CPU: haswell
  • Kernel
Linux 5.10.7-zen1-1-zen #1 ZEN SMP PREEMPT Wed, 13 Jan 2021 13:23:18 +0000 x86_64 GNU/Linux


clang-tidy executable binary that PlatformIO bring is not working on my machine (Arch Linux) because of is not found.

I appreciate all the questions, feedback, or ideas to this problem!


The clang-tidy binary distributed there links against libncurses5, which is being deprecated by version 6, however, as seen e.g. here, you can either symlink v6 to v5 or install a compatibility pacakge.

If PIO would package a binary linked against a newer version it would in turn break distributions which don’t have the new version available – there’s always a caveat.

1 Like

Thanks! I’m sorry I did not spend much attention for this problem to find the solution, because my first workaround is working just fine :slight_smile: .

1 Like