scalameta / metals-vscode

Visual Studio Code extension for Metals
https://marketplace.visualstudio.com/items?itemName=scalameta.metals#overview
Apache License 2.0
298 stars 75 forks source link

Fails to download on Windows with output "Error creating cache directory...Caused by: java.nio.file.AccessDeniedException: C:\Program Files\Microsoft VS Code\null" #1448

Closed jarhart closed 8 months ago

jarhart commented 8 months ago

Describe the bug

Fails with message:

Failed to download Metals, make sure you have an internet connection, the Metals version '1.2.0' is correct and the Java Home 
'C:\Program Files\Java\jdk-17' is valid. You can configure the Metals version and Java Home in the settings.See 
https://scalameta.org/metals/docs/editors/vscode/#http-proxy for instructions if you are using an HTTP proxy.

Output

Java home: C:\Program Files\Java\jdk-17
Metals version: 1.2.0
Exception in thread "main" java.lang.RuntimeException: Error creating cache directory
    at coursier.bootstrap.launcher.c.a(Unknown Source)
    at coursier.bootstrap.launcher.Launcher.main(Unknown Source)
Caused by: java.nio.file.AccessDeniedException: C:\Program Files\Microsoft VS Code\null
    at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89)
    at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
    at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
    at java.base/sun.nio.fs.WindowsFileSystemProvider.createDirectory(WindowsFileSystemProvider.java:521)
    at java.base/java.nio.file.Files.createDirectory(Files.java:700)
    at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:807)
    at java.base/java.nio.file.Files.createDirectories(Files.java:793)
    at coursier.bootstrap.launcher.u.a(Unknown Source)
    at coursier.bootstrap.launcher.p.a(Unknown Source)
    at coursier.bootstrap.launcher.o.a(Unknown Source)
    ... 2 more

Installation:

Additional context

tgodzik commented 8 months ago

Thanks for reporting! Looks like an issue we already solved for other things in Metals, but this time it's an issue with coursier. I will try and update coursier binary, this might be fixed there, though not 100% sure about it.

tgodzik commented 8 months ago

A workaround could be installing coursier manually locally, we should be able to pick it up and not run the boostrap.

https://get-coursier.io/docs/cli-installation#windows

tgodzik commented 8 months ago

https://github.com/scalameta/metals-vscode/issues/1450 <- should solve it, we want to work on it sometime soon

jarhart commented 8 months ago

A workaround could be installing coursier manually locally, we should be able to pick it up and not run the boostrap.

https://get-coursier.io/docs/cli-installation#windows

That worked great! Thank you!

tgodzik commented 8 months ago

Good to hear that, since this will be solved by https://github.com/scalameta/metals-vscode/issues/1450 I will close this one.