# Unable to change sonar.working.directory with sonar-scanner-cli:latest docker image (v10)

**URL:** <https://community.sonarsource.com/t/unable-to-change-sonar-working-directory-with-sonar-scanner-cli-latest-docker-image-v10/118398>\
**Category:** SonarQube Server / Community Build\
**Tags:** scanner\
**Created:** [July 4, 2024, 10:46am UTC](https://community.sonarsource.com/t/unable-to-change-sonar-working-directory-with-sonar-scanner-cli-latest-docker-image-v10/118398 "2024-07-04T10:46:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dani](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/dani/32/59108_2.png) [@Dani](https://community.sonarsource.com/u/Dani)\
**Post date:** [July 4, 2024, 10:46am UTC](https://community.sonarsource.com/t/unable-to-change-sonar-working-directory-with-sonar-scanner-cli-latest-docker-image-v10/118398/1 "2024-07-04T10:46:35Z")

</div>

- SonarQube Community Edition Version 9.9.4 (build 87374) (docker)

Using Sonar Scanner CLI (sonarsource/sonar-scanner-cli:latest) which is the latest v10 we are no longer able to set sonar.working.directory in our Jenkins Pipelines. Even if we set the parameter sonar.working.directory to e.g. /sonar/.scannerwork it gets overridden with /tmp/.scannerwork.

`WARN: Property ‘sonar.working.directory’ with value ‘/sonar/.scannerwork’ is overridden with value ‘/tmp/.scannerwork’`

The .scannerwork directory needs to be available in each Jenkins workspace for Quality Gate to be resolved for each job. In this case we volume mount the Jenkins workspace into /sonar path in the sonar-scanner-cli container.

Downgrading to sonarsource/sonar-scanner-cli:5.0.1 works as intended.

See this thread for further information and related change that broke this behaviour:

> [@Permissions error during SonarScanner CLI Docker execution](https://community.sonarsource.com/t/permissions-error-during-sonarscanner-cli-docker-execution/115839):
>
> SonarScanner 5.0.1.3006 Java 17.0.11 Alpine (64-bit) Linux 5.15.0-1041-azure amd64 SonarQube server 10.2.0.77647 Getting this error on pull request- ERROR: Error during SonarScanner execution org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ClassRealm{javascript}-org.sonar.plugins.javascript.eslint.BridgeServerImpl': Unsatisfied dependency expressed through constructor parameter 4; nested exception is org.springframework.beans.factory.Unsatisf…

Please suggest workaround if setting `sonar.working.directory` no longer is supported in this way.

Thanks!

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [July 5, 2024, 3:25pm UTC](https://community.sonarsource.com/t/unable-to-change-sonar-working-directory-with-sonar-scanner-cli-latest-docker-image-v10/118398/2 "2024-07-05T15:25:30Z")

</div>

Hey there.

> [@Dani](#):
>
> The .scannerwork directory needs to be available in each Jenkins workspace for Quality Gate to be resolved for each job. In this case we volume mount the Jenkins workspace into /sonar path in the sonar-scanner-cli container.

Are you using the [SonarQube extension for Jenkins](https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/jenkins-extension-sonarqube/) to call the Quality Gate, or something custom that you’ve built?

I’m asking because it might be just as easy to start using [`sonar.qualitygate.wait`](https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/ci-integration/overview/#quality-gate-fails) in your pipeline and avoid the working directory question altogether.

---

<div class="post-metadata">

**Author:** ![Dani](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/dani/32/59108_2.png) [@Dani](https://community.sonarsource.com/u/Dani)\
**Post date:** [July 8, 2024, 9:35am UTC](https://community.sonarsource.com/t/unable-to-change-sonar-working-directory-with-sonar-scanner-cli-latest-docker-image-v10/118398/3 "2024-07-08T09:35:25Z")

</div>

Hello!

Correct, we’re using `withSonarQubeEnv` and `waitForQualityGate` Pipeline steps.

---

<div class="post-metadata">

**Author:** ![Dani](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/dani/32/59108_2.png) [@Dani](https://community.sonarsource.com/u/Dani)\
**Post date:** [July 8, 2024, 11:46am UTC](https://community.sonarsource.com/t/unable-to-change-sonar-working-directory-with-sonar-scanner-cli-latest-docker-image-v10/118398/4 "2024-07-08T11:46:27Z")

</div>

Testing `sonar.qualitygate.wait` with sonar-scanner-cli it works with v5.0.1 but when running the latest sonar-scanner-cli container (v10) it fails to start because of lack of permissions for /tmp directory.  
We run the sonar-scanner-cli container with non-priv Jenkins node user (id -u:id -g) and would like to avoid a scenario where we have workspace file/folder user permission discrepancies and having to volume mount multiple paths for the container to function, and as mentioned previously it doesn’t work to override the working dir with the latest container image version.

If we volume mount the /tmp directory from the Jenkins host node into /tmp in the container it works but I’m not sure what kind of impact (if any) this will have at scale when running multiple builds with shared /tmp as sonar working directory.

If we are able to override and set the `sonar.working.directory` for the container we could just use the same directory as the workspace (like before) and avoid this situation.

```auto
 WARN: Property 'sonar.working.directory' with value '/sonar/.scannerwork' is overridden with value '/tmp/.scannerwork'
 ...
 11:03:14.649 INFO: Working dir: /tmp/.scannerwork
 11:03:14.649 DEBUG: Project global encoding: UTF-8, default locale: en_US
 11:03:14.666 INFO: ------------------------------------------------------------------------
 11:03:14.667 INFO: EXECUTION FAILURE
 11:03:14.667 INFO: ------------------------------------------------------------------------
 11:03:14.667 INFO: Total time: 3.398s
 11:03:14.706 INFO: Final Memory: 13M/68M
 11:03:14.706 INFO: ------------------------------------------------------------------------
 11:03:14.706 ERROR: Error during SonarScanner execution
 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ClassRealm{javascript}-org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl': Unsatisfied dependency expressed through constructor parameter 4; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AnalysisTempFolder' defined in org.sonar.scanner.analysis.AnalysisTempFolderProvider: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.sonar.api.utils.TempFolder]: Factory method 'provide' threw exception; nested exception is java.lang.IllegalStateException: Unable to create root temp directory /tmp/.scannerwork/.sonartmp

```

Thanks!

---

<div class="post-metadata">

**Author:** ![Dani](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/dani/32/59108_2.png) [@Dani](https://community.sonarsource.com/u/Dani)\
**Post date:** [July 18, 2024, 8:47am UTC](https://community.sonarsource.com/t/unable-to-change-sonar-working-directory-with-sonar-scanner-cli-latest-docker-image-v10/118398/7 "2024-07-18T08:47:35Z")

</div>

bump!

---

<div class="post-metadata">

**Author:** ![Csaba\_Feher](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/csaba_feher/32/27205_2.png) [@Csaba\_Feher](https://community.sonarsource.com/u/Csaba_Feher)\
**Post date:** [July 19, 2024, 7:08am UTC](https://community.sonarsource.com/t/unable-to-change-sonar-working-directory-with-sonar-scanner-cli-latest-docker-image-v10/118398/8 "2024-07-19T07:08:04Z")

</div>

Hi Dani,

We spent time to investigate and find the route cause of the issue. I can confirm that this is a bug. We will try to address with the upcoming scanner v6 updates. I will inform you after the bugfix is released.

Thanks  
Csaba

---

<div class="post-metadata">

**Author:** ![Dani](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/dani/32/59108_2.png) [@Dani](https://community.sonarsource.com/u/Dani)\
**Post date:** [February 11, 2025, 5:21pm UTC](https://community.sonarsource.com/t/unable-to-change-sonar-working-directory-with-sonar-scanner-cli-latest-docker-image-v10/118398/10 "2025-02-11T17:21:26Z")

</div>

Can someone confirm if this has been fixed or not?

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [February 12, 2025, 8:29am UTC](https://community.sonarsource.com/t/unable-to-change-sonar-working-directory-with-sonar-scanner-cli-latest-docker-image-v10/118398/11 "2025-02-12T08:29:02Z")

</div>

Hey @Dani

The ticket is [SCANDOCKER-33](https://sonarsource.atlassian.net/browse/SCANDOCKER-33), and I can confirm it’s still open.

---

<div class="post-metadata">

**Author:** ![Dani](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/dani/32/59108_2.png) [@Dani](https://community.sonarsource.com/u/Dani)\
**Post date:** [February 12, 2025, 9:14am UTC](https://community.sonarsource.com/t/unable-to-change-sonar-working-directory-with-sonar-scanner-cli-latest-docker-image-v10/118398/12 "2025-02-12T09:14:07Z")

</div>

Thanks, Colin! Appreciate the ticket link.
