Unable to create shared memory (Permission denied)

Helllo Commuinty,

I am a first time user of SonarQube Community Edition ,
I am trying run the sonar.sh start and running into the error below.
I am running this on mac, And have tried to run the .sh with sudo, I then get another error "elastic search cannot be run as a root.

2022.04.11 23:23:18 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /var/sonarqube/temp
2022.04.11 23:23:18 ERROR app[][o.s.application.App] Startup failure
java.lang.IllegalArgumentException: Unable to create shared memory :
	at org.sonar.process.sharedmemoryfile.AllProcessesCommands.<init>(AllProcessesCommands.java:103)
	at org.sonar.application.AppFileSystem.reset(AppFileSystem.java:63)
	at org.sonar.application.App.start(App.java:53)
	at org.sonar.application.App.main(App.java:81)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.io.FileNotFoundException: /var/sonarqube/temp/sharedmemory (Permission denied)
	at java.base/java.io.RandomAccessFile.open0(Native Method)
	at java.base/java.io.RandomAccessFile.open(RandomAccessFile.java:346)
	at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:260)
	at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:215)
	at org.sonar.process.sharedmemoryfile.AllProcessesCommands.<init>(AllProcessesCommands.java:100)
	... 9 common frames omitted
<-- Wrapper Stopped

Hi,

Welcome to the community!

I’m going to go backwards here.

You can’t run SonarQube as root; as you’ve seen, Elasticsearch refuses to start. So you need a different (ideally, dedicated) user to run SonarQube as. And that user should have all permissions (777) on the SonarQube directory, recursively. The error you’re getting appears to be a case of the user not having the necessary file permissions recursively.

 
HTH,
Ann