Cache not found for input keys: sonar-scanner-cli-6.2.1.4610-Linux-X64

I am encountering an issue while running the SonarCloud GitHub Action sonarqube-scan-action@v4.2.1. The error arises during the caching process for the sonar-scanner-cli, where the cache is reported as “not found.” As a result, the step to execute the scanner fails with a java: not found error. Below are the relevant portions of the workflow log and code snippet.

Logs:
Run actions/cache@v4
with:
path: /home/runner/work/_temp/sonar-scanner-cli-6.2.1.4610-Linux-X64
key: sonar-scanner-cli-6.2.1.4610-Linux-X64
enableCrossOsArchive: false
fail-on-cache-miss: false
lookup-only: false
save-always: false
env:
SONAR_TOKEN: ***
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
/usr/bin/docker exec abc123def456gh78ij901kl23mnop45qrstuv sh -c “cat /etc/*release | grep ^ID”
Cache not found for input keys: sonar-scanner-cli-6.2.1.4610-Linux-X64

Subsequent Error:
/__w/_temp/sonar-scanner-cli-6.2.1.4610-Linux-X64/bin/sonar-scanner: exec: line 66: /__w/_temp/sonar-scanner-cli-6.2.1.4610-Linux-X64/jre/bin/java: not found
Error: Process completed with exit code 127.

Workflow file code snippet:

  • name: Analyze with SonarCloud
    uses: SonarSource/sonarqube-scan-action@v4.2.1
    with:
    args: >
    -Dsonar.organization=example-org
    -Dsonar.projectKey=example-project-key
    -Dsonar.sources=src,lib
    -Dsonar.exclusions=./node_modules
    -Dsonar.host.url=https://sonarcloud.io
    -Dsonar.projectName=example-project
    -Dsonar.token=${{ env.SONAR_TOKEN }}
    -Dsonar.javascript.node.maxspace=4096
    env:
    SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

Hi @Adi29,
Thanks for reporting your issue to our community.

The Cache not found for input keys: sonar-scanner-cli-6.2.1.4610-Linux-X64 message informs that the scanner is not in cache (because it was never cached for this combination of OS and Architecture or because the cache has been invalidated).

This is not an issue per se: when there is a cache miss, the install-sonar-scanner-cli.sh is executed, to download the Sonar Scanner CLI. Something like the following:

...
Cache not found for input keys: sonar-scanner-cli-6.2.1.4610-Linux-X64
Run ${GITHUB_ACTION_PATH}/scripts/install-sonar-scanner-cli.sh
  ${GITHUB_ACTION_PATH}/scripts/install-sonar-scanner-cli.sh
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    SONAR_HOST_URL: http://localhost:9000
    INPUT_SCANNERVERSION: 6.2.1.4610
    INPUT_SCANNERBINARIESURL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli
mkdir -p /home/runner/work/_temp/sonarscanner
cd /home/runner/work/_temp/sonarscanner
SCANNER_FILE_NAME=sonar-scanner-cli-6.2.1.4610-linux-x64.zip
SCANNER_URI=https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.2.1.4610-linux-x64.zip
command -v wget
wget --no-verbose --user-agent=sonarqube-scan-action https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.2.1.4610-linux-x64.zip
2025-01-08 11:31:12 URL:https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.2.1.4610-linux-x64.zip [57996219/57996219] -> "sonar-scanner-cli-6.2.1.4610-linux-x64.zip" [1]
unzip -q -o sonar-scanner-cli-6.2.1.4610-linux-x64.zip
SCANNER_UNZIP_FOLDER=sonar-scanner-6.2.1.4610-linux-x64
SCANNER_LOCAL_FOLDER=/home/runner/work/_temp/sonar-scanner-cli-6.2.1.4610-Linux-X64
'[' -d /home/runner/work/_temp/sonar-scanner-cli-6.2.1.4610-Linux-X64 ']'
mv -f sonar-scanner-6.2.1.4610-linux-x64 /home/runner/work/_temp/sonar-scanner-cli-6.2.1.4610-Linux-X64

After that, the downloaded Sonar Scanner CLI is cached:

And used at the next run:

Run actions/cache@v4
  
Received 0 of 52684795 (0.0%), 0.0 MBs/sec
Cache Size: ~50 MB (52684795 B)
/usr/bin/tar -xf /home/runner/work/_temp/dbb0cb4f-4739-4b7f-b098-e4ac97e6964d/cache.tzst -P -C /home/runner/work/dart-tools-test1/dart-tools-test1 --use-compress-program unzstd
Received 52684795 of 52684795 (100.0%), 25.1 MBs/sec
Cache restored successfully
Cache restored from key: sonar-scanner-cli-6.2.1.4610-Linux-X64
Run echo "${RUNNER_TEMP}/sonar-scanner-cli-6.2.1.4610-Linux-X64/bin" >> $GITHUB_PATH
  
Run ${GITHUB_ACTION_PATH}/scripts/run-sonar-scanner-cli.sh -Dsonar.projectKey=dart-project -Dsonar.login=admin -Dsonar.*** --debug
...

I would have a few questions to better understand your scenario:

  1. are you using alpine? If so, could you try using ubuntu-latest, for example?
  2. did it use to work with previous versions of the GitHub Action and stopped working with the new version of the action, or it is a new pipeline being setup?
  3. are you running the GitHub action on a self-hosted runner?
  4. could you share the full logs that come after the actions/cache action execution?
  • in particular, is the install-sonar-scanner-cli.sh executed correctly?
  1. are you running an antivirus program in your GitHub runner, that may impede the creation (or delete) the java program under jre/bin/?

Thanks,
Antonio

Hi all,
I’ve run into exactly this problem as well. It’s not really clear to me what is going on. From what I am understanding the problem is not related to the cache miss, it looks like something is going wrong when installing it for the first time - but I am not sure what.
I will attach a run with debug output, maybe that helps you:

##[debug]Evaluating: secrets.SONAR_TOKEN
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'SONAR_TOKEN'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating: secrets.SONAR_HOST_URL
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'SONAR_HOST_URL'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating condition for step: 'Run sonarsource/sonarqube-scan-action@v4.2.1'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Run sonarsource/sonarqube-scan-action@v4.2.1
##[debug]Register post job cleanup for action: sonarsource/sonarqube-scan-action@v4.2.1
##[debug]Loading inputs
##[debug]Loading env
Run sonarsource/sonarqube-scan-action@v4.2.1
  with:
    args: -Dsonar.verbose=false -Djavax.net.debug="ssl,handshake"
  
    scannerVersion: 6.2.1.4610
    scannerBinariesUrl: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli
  env:
    SONAR_TOKEN: ***
    SONAR_HOST_URL: ***
##[debug]Evaluating: inputs.projectBaseDir
##[debug]Evaluating Index:
##[debug]..Evaluating inputs:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'projectBaseDir'
##[debug]=> ''
##[debug]Result: ''
##[debug]Evaluating condition for step: 'run'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: run
##[debug]Loading inputs
##[debug]....Evaluating runner:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'os'
##[debug]..=> 'Linux'
##[debug]..Evaluating Index:
##[debug]....Evaluating runner:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'arch'
##[debug]..=> 'X64'
##[debug]=> '/home/runner/work/_temp/sonar-scanner-cli-6.2.1.4610-Linux-X64/jre'
##[debug]Result: '/home/runner/work/_temp/sonar-scanner-cli-6.2.1.4610-Linux-X64/jre'
##[debug]Evaluating condition for step: 'run'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: run
##[debug]Loading inputs
##[debug]Evaluating: format('${{GITHUB_ACTION_PATH}}/scripts/run-sonar-scanner-cli.sh {0}', inputs.args)
##[debug]Evaluating format:
##[debug]..Evaluating String:
##[debug]..=> '${{GITHUB_ACTION_PATH}}/scripts/run-sonar-scanner-cli.sh {0}'
##[debug]..Evaluating Index:
##[debug]....Evaluating inputs:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'args'
##[debug]..=> '-Dsonar.verbose=false -Djavax.net.debug="ssl,handshake"
##[debug]'
##[debug]=> '${GITHUB_ACTION_PATH}/scripts/run-sonar-scanner-cli.sh -Dsonar.verbose=false -Djavax.net.debug="ssl,handshake"
##[debug]'
##[debug]Result: '${GITHUB_ACTION_PATH}/scripts/run-sonar-scanner-cli.sh -Dsonar.verbose=false -Djavax.net.debug="ssl,handshake"
##[debug]'
##[debug]Loading env
Run ${GITHUB_ACTION_PATH}/scripts/run-sonar-scanner-cli.sh -Dsonar.verbose=false -Djavax.net.debug="ssl,handshake"
##[debug]bash --noprofile --norc -e -o pipefail /__w/_temp/7df4104c-58e1-4620-87fe-563c2e2f2c1b.sh
+ sonar-scanner --debug -Dsonar.verbose=false -Djavax.net.debug=ssl,handshake
/__w/_temp/sonar-scanner-cli-6.2.1.4610-Linux-X64/bin/sonar-scanner: exec: line 66: /__w/_temp/sonar-scanner-cli-6.2.1.4610-Linux-X64/jre/bin/java: not found
Error: Process completed with exit code 127.
##[debug]Finished: run
##[debug]Finishing: Run sonarsource/sonarqube-scan-action@v4.2.1