Chris Harris
Chris Harris

Reputation: 1329

SonarQube - Temp directory is not writable

I'm installing SonarQube v5.0.1.

I'm running Windows Server 2012 64-bit, Java 1.8 64-bit, and the SonarQube windows-x86-64 wrapper.

SonarQube keeps throwing the following error:

WrapperSimpleApp: Encountered an error running main: java.lang.IllegalStateException: Temp directory is not writable: C:\Windows\system32\config\systemprofile\AppData\Local\Temp\
java.lang.IllegalStateException: Temp directory is not writable: C:\Windows\system32\config\systemprofile\AppData\Local\Temp\
    at org.sonar.process.MinimumViableSystem.checkWritableDir(MinimumViableSystem.java:60)
    at org.sonar.process.MinimumViableSystem.checkWritableTempDir(MinimumViableSystem.java:52)
    at org.sonar.process.MinimumViableSystem.check(MinimumViableSystem.java:45)
    at org.sonar.application.App.main(App.java:113)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: The system cannot find the path specified
    at java.io.WinNTFileSystem.createFileExclusively(Native Method)
    at java.io.File.createTempFile(Unknown Source)
    at org.sonar.process.MinimumViableSystem.checkWritableDir(MinimumViableSystem.java:57)
    ... 9 more
<-- Wrapper Stopped

Why does SonarQube keep trying to write to C:\Windows\System32\config\systemprofile\AppData\Local instead of C:\Windows\SysWOW64\config\systemprofile\AppData\Local?

To get rid of this error in previous installations, I've had to create a Temp folder in C:\Windows\System32\config\systemprofile\AppData\Local and fiddle with the read/write settings and or permissions to get SonarQube to stop complaining.

UPDATE: This is a huge problem, because I can't start SonarQube as a Windows Service. What's weird is that I already had SonarQube installed and running as a Windows Service. Today, I stopped the service, and now I can't start the service anymore. I've set the Temp folder's permissions to be not Read-Only and so that Everyone has Full Control (not ideal, I know...)

Still, the Temp error prevents SonarQube from starting.

Upvotes: 11

Views: 11414

Answers (5)

Shaillesh Tannu
Shaillesh Tannu

Reputation: 11

In case of Windows (specifically Windows 10), delete the file under temp folder [under sonar folders] and run startSonar.bat. It should work.

Upvotes: 0

Piotr Kozak
Piotr Kozak

Reputation: 98

I had the same error when running some sonar analysis. It turned out that in wrapper.conf I had to add

set.TMPDIR=c:/tmp

with path to the existing tmp directory and of course service needed to be reinstalled (UninstallNTService.bat / InstallNTService.bat)

Upvotes: 0

user6495210
user6495210

Reputation:

I had the same issue today with sonarqube 5.6 and Windows Server 2008 R2. Nothing of the above worked for me but what fixed the issue was defining a system variable TMPDIR pointing to another temp-directory e.g. C:\TMP

Upvotes: 0

Tom Howard
Tom Howard

Reputation: 6687

This can also be fixed by setting the java.io.tmpdir java property to a writable directory. e.g., in conf/wrapper.conf change

wrapper.java.additional.1=-Djava.awt.headless=true

to

wrapper.java.additional.1=-Djava.awt.headless=true -Djava.io.tmpdir=E:/sonarqube-5.1/temp

Upvotes: 33

Sean Tomlins
Sean Tomlins

Reputation: 375

I had the same error in my sonar log when trying to start the service after I had installed it.

I had JAVA_HOME and x64 all correctly set up.

I managed to resolve the issue in the log above by changing the 'Log On As' for the installed service to 'NETWORK SERVICE' (without a password), then started the service. By default it had set the Log On As to Local System.

Probably another thing worth mentioning is if you're setting up SonarQube for the first time it may be best to get the website working before installing the service, otherwise debugging is a bit of a pain.

Upvotes: 10

Related Questions