SonarQube - Temp directory is not writable [duplicate]
Asked Answered
G

5

11

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.

Garibold answered 12/3, 2015 at 20:44 Comment(0)
C
33

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
Chinua answered 11/5, 2015 at 1:47 Comment(4)
Thank you! This worked, and the accepted answer didn't! Caveat lector. Although, the "right" thing to do is add the line wrapper.java.additional.2=-Djava.io.tmpdir=E:/sonarqube-5.1/temp since it is a separate commandline argument from the other -D argument.Calcimine
Thanks, this worked. I added wrapper.java.additional.1=-Djava.awt.headless=true -Djava.io.tmpdir=../../tempScandent
I had to do this after upgrading to 5.1.2 from 4.5.1. The service worked as expected for a long time before. Both service versions, 32bit and 64bit, displayed the error mentioned in the original question after upgrading.Britain
THANK YOU VERY MUCH!! 2 days looking for this answer. I was unable to start sonar as a service under local system account. The drive that the temp directory was on was a shared drive. This resolved issue.Photophilous
D
10

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.

Delores answered 17/4, 2015 at 2:35 Comment(0)
C
0

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

Chinachinaberry answered 21/6, 2016 at 16:20 Comment(0)
H
0

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)

Helgeson answered 10/7, 2016 at 18:9 Comment(0)
A
0

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

Ailsun answered 10/9, 2019 at 9:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.