ALM used: GitHub CI system used: GitHub Actions Languages: JavaScript Project: Public SonarCloud project
Error:
When running sonarqube-scan-action as-is (from official setup instructions), the workflow fails with:
/Users/runner/work/_actions/SonarSource/sonarqube-scan-action/v5/scripts/run-sonar-scanner-cli.sh: line 80: scanner_args[0]: unbound variable
This seems to happen because scanner_args is not defined unless passed explicitly.
Steps to reproduce:
Follow the instructions to integrate SonarCloud with a JavaScript repo using GitHub Actions.
Use the standard workflow template provided by the SonarCloud UI.
Trigger the workflow.
Expected result:
The scan should complete successfully using default settings.
Actual result:
Fails with scanner_args[0]: unbound variable error.
Potential cause:
The script run-sonar-scanner-cli.sh references scanner_args[0] without checking whether scanner_args is defined.
Suggested fix:
Use a conditional or default value to avoid unbound variable access.
Just to clarify — I’m using sonarcloud-github-action@master, not sonarqube-scan-action@v5.
The error I described earlier occurred when trying the @v5 version without explicitly passing args.
Yes — that’s exactly why I added projectBaseDir: ..
I initially followed the official setup instructions using sonarqube-scan-action@v5, but the workflow failed with this error:
/Users/runner/work/_actions/SonarSource/sonarqube-scan-action/v5/scripts/run-sonar-scanner-cli.sh: line 80: scanner_args[0]: unbound variable
Apparently, the script tries to access scanner_args[0] even when no args are passed at all. To avoid the crash, I tried passing something manually — just projectBaseDir: . — to make it work.
Eventually, I switched to sonarcloud-github-action@master, and everything started working smoothly without needing to define args.