Skip to content
Latchkey

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.

sonar-scanner
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

  1. Confirm where the source lives relative to where the scanner runs.
  2. Set sonar.sources to that path, or set the base directory for a subproject.
  3. Re-run and confirm the scan indexes files.
sonar-project.properties
sonar.sources=src
sonar.tests=tests

Run the scanner from the project subdirectory

For a monorepo, set the working directory (or projectBaseDir) to the subproject so relative source paths resolve.

.github/workflows/ci.yml
- uses: SonarSource/sonarqube-scan-action@v4
  with:
    projectBaseDir: services/api

How to prevent it

  • Keep sonar.sources relative to a stable base directory.
  • Set projectBaseDir explicitly in monorepos.
  • Verify the scan indexes the expected file count in the log.

Frequently asked questions

What causes ""No files nor directories matching""?
The property names a directory that does not exist relative to the base directory the scanner computed.
How do I fix "No files nor directories matching"?
Point sonar.sources at the real code directory

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card