File was unable to be removed Error: EACCES: permission denied, unlink 'scannerwork/.sonar_lock'

I am using SonarCloud and I am trying to run the GitHub workflow on a Linux based self-hosted runner. I have a workflow for frontend javascript, typescript project and everytime the scan runs, the subsequent scans fail stating that

File was unable to be removed Error: EACCES: permission denied, unlink ‘scannerwork/.sonar_lock’

I will have to manually delete the sonar_lock file and then only the other scans run.

This issue doesn’t happen when I run the sonar scan workflow for a BE project (.Net) on the self-hosted runner. It only happens for the FE workflow as below.

This is the workflow I am running

    needs: changes
    runs-on: self-hosted
      - name: Checkout code
        uses: actions/checkout@v3
          fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

      - name: set node to 16
        uses: actions/setup-node@v3
          node-version: "16"

      - name: set npm to 6
        run: npm i -g npm@6

      - name: install dependencies
        working-directory: ./UI/QueryBuilder
        run: npm ci

      - name: run tests
        working-directory: ./UI/QueryBuilder
        run: npm test --coverage --coverageReporters lcov

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

What am I missing here?

Hey there.

It looks like a similar issue was reported on the sonarqube-scan-action: Action leaves .scannerwork owned by root · Issue #22 · SonarSource/sonarqube-scan-action · GitHub

A workaround is available in that ticket, and I’ll flag this for attention from the team responsible for the SonarCloud action.

We are working on a fix, we’ll have it released soon.

Good news, sonarcloud-github-action v2.1.0 has been released which includes a fix for this issue. Let us know if the issue persists.

1 Like

Thank you for the quick action. I will check and update you.

The scans are running fine now without any errors on the self-hosted runner. Thank you!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.