Sonar scanner does not find header file

I’m using

  • SonarQube Developer Edition v2025.1.5 (119025), and
  • Scanner CLI version 6.2.1.4610 (but also tested with 8.0.1.6346, same problem).

It’s probably not relevent, but SonarQube is deployed via Docker.

For our scanning I get:

The analyzer was not able to find file
  pybind11/embed.h
  included from file /path/to/src/cli/main.cpp
This impacts the quality of the analysis and leads to inaccurate results.
Please check that the file exists on your machine during the analysis:
* if it doesn't, find a way to persist it after your build;
  all the files accessed during the build should be accessible during the analysis
* if it does, please contact SonarSource support providing
  the full path to the file
    pybind11/embed.h
  and the file
    /path/to/sonar-cfamily-reproducer.tar.xz

We use conan for some of our dependencies which makes sure this file pybind11/embed.h exists.

Everything I checked looks good so far.

cat build/compile_commands.json | grep /path/to/src/cli/main.cpp shows -isystem /root/.conan2/p/pybina983d04c7d0bc/p/include

ls /root/.conan2/p/pybina983d04c7d0bc/p/include/pybind11/ shows embed.h (among others).

What I also found weird, is that in main.cpp, the #include <pybind11/pybind11.h> statement appears earlier than #include <pybind11/embed.h>, but the scanner is unhappy about pybind11/embed.h.

If needed, I can provide sonar-cfamily-reproducer.tar.xz, but not publicly.

Thanks in advance! :slight_smile:

Hi @trinklin,

thank you for your detailed report.

Yes, having a sonar-cfamily-reproducer.tar.xz file would help us investigate this problem.

I’m starting a private thread with you so that you can provide this file privately.

Bug: 'file not found' is cached and not checked again - #4 by Abbas solved it.

1 Like