Getting "AccessDeniedException" when I try to run a HelloWorld application in IntelliJ with WSL2

Viewed 708

Trying to setup IntelliJ for use with wsl2 on win10 following jetbrains instructions here

  • installed ubuntu20.04 via the ms store and created a default user.
  • installed sdkman with open jdk 11.0.12
  • used IntelliJ to create a new HelloWorld java project in the wsl2 environment.

When I build/run the project in IntelliJ I get the following exception:

java.nio.file.AccessDeniedException: /home/paul/.cache/JetBrains/IdeaIC2021.2/compile-server/helloworld_ddb4f9d0/timestamps
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:389)
at java.base/java.nio.file.Files.createDirectory(Files.java:690)
at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:797)
at java.base/java.nio.file.Files.createDirectories(Files.java:783)
at com.intellij.util.io.ResizeableMappedFile.ensureParentDirectoryExists(ResizeableMappedFile.java:175)
at com.intellij.util.io.ResizeableMappedFile.<init>(ResizeableMappedFile.java:67)
at com.intellij.util.io.PersistentBTreeEnumerator.<init>(PersistentBTreeEnumerator.java:73)
at com.intellij.util.io.PersistentEnumerator.createDefaultEnumerator(PersistentEnumerator.java:66)
at com.intellij.util.io.PersistentMapImpl.<init>(PersistentMapImpl.java:135)
at com.intellij.util.io.PersistentMapBuilder.buildImplementation(PersistentMapBuilder.java:64)
at com.intellij.util.io.PersistentMapBuilder.build(PersistentMapBuilder.java:41)
at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:39)
at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:54)
at org.jetbrains.jps.incremental.storage.AbstractStateStorage.createMap(AbstractStateStorage.java:124)
at org.jetbrains.jps.incremental.storage.AbstractStateStorage.<init>(AbstractStateStorage.java:29)
at org.jetbrains.jps.incremental.storage.FileTimestampStorage.<init>(FileTimestampStorage.java:27)
at org.jetbrains.jps.incremental.storage.ProjectStamps.<init>(ProjectStamps.java:41)
at org.jetbrains.jps.cmdline.BuildRunner.load(BuildRunner.java:98)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:295)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:146)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:218)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)

Tried with community versions of 2021.2 and 2021.2.1.

On the wsl2 environment IntelliJ is creating the project files and caches owned by root. Is that possibly related? Although it doesnt seem to have any problem read/write the src files.

Also raised it on youtrack here but I'm wondering if its a problem with my setup rather than a bug with IntelliJ. New to wsl2

1 Answers

See updates on the youtrack ticket.

Still unsure why IntelliJ initially created the structure as root but deleting the .cache directory and restarting IntelliJ caused all folders to then be created as my user fixing the problem for me.

Related