SonarScanner "No files nor directories matching sonar.sources" in CI
The scanner resolved sonar.sources against its base directory and found nothing there. The path is wrong, or the scanner is running from the wrong directory, so it has no code to analyze.
What this error means
The scanner fails or warns with "No files nor directories matching 'src' in '/home/runner/work/app'" and analyzes zero files.
ERROR: Invalid value of sonar.sources for my-project
ERROR: The folder 'src' does not exist for 'my-project' (base directory = /home/runner/work/app/app)Common causes
sonar.sources points at a missing path
The property names a directory that does not exist relative to the base directory the scanner computed.
The scanner runs from the wrong working directory
A monorepo or subproject layout puts the code under a subfolder, but the scan runs from the repo root without adjusting the base directory.
How to fix it
Point sonar.sources at the real code directory
- Confirm where the source lives relative to where the scanner runs.
- Set
sonar.sourcesto that path, or set the base directory for a subproject. - Re-run and confirm the scan indexes files.
sonar.sources=src
sonar.tests=testsRun the scanner from the project subdirectory
For a monorepo, set the working directory (or projectBaseDir) to the subproject so relative source paths resolve.
- uses: SonarSource/sonarqube-scan-action@v4
with:
projectBaseDir: services/apiHow to prevent it
- Keep
sonar.sourcesrelative to a stable base directory. - Set
projectBaseDirexplicitly in monorepos. - Verify the scan indexes the expected file count in the log.