GitHub Action sonarqube-scan-action fails due to unbound scanner_args[0]

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:

  1. Follow the instructions to integrate SonarCloud with a JavaScript repo using GitHub Actions.
  2. Use the standard workflow template provided by the SonarCloud UI.
  3. 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.

Hi,

Welcome to the community!

Could you share the pipeline?

 
Thx,
Ann

Thanks for the warm welcome, Ann!

Sure — here’s the relevant part of my pipeline:

jobs:
  sonarscan:
    name: SonarCloud
    runs-on: macos-latest

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: SonarCloud Scan
        uses: SonarSource/sonarcloud-github-action@master
        with:
          projectBaseDir: .
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 

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.

Hi,

So that’s the reason you’re doing this?

Because without any args, you get an error, so you made one up?

Also, could we have that full error analysis log, please?

 
Thx,
Ann

Hi Ann,

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.

Thanks again!
Denis

Hi,

For the sake of i-dotting, can I please have that full analysis log?

 
Thx,
Ann

0_SonarQube.txt (14.9 KB)

Hi,

Thanks!

I’ve flagged this for the experts.

 
Ann