I'm attempting to use Metals with the latest version of Atom (1.33) however when I attempt to import a project I get the following error in the log:
warn Unable to automatically connect to build server.
error Unexpected error initializing server
java.nio.file.FileAlreadyExistsException: /home/keir/.sbt/1.0/plugins
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:88)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384)
at java.nio.file.Files.createDirectory(Files.java:674)
at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781)
at java.nio.file.Files.createDirectories(Files.java:727)
at scala.meta.internal.metals.BloopInstall$.scala$meta$internal$metals$BloopInstall$$writeGlobalPluginFile(BloopInstall.scala:191)
at scala.meta.internal.metals.BloopInstall.runUnconditionally(BloopInstall.scala:53)
at scala.meta.internal.metals.BloopInstall.$anonfun$runIfApproved$2(BloopInstall.scala:130)
at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
@keirlawson thanks for reporting!
Metals needs to write a metals.sbt file inside the ~/.sbt/1.0/plugins/ directoy, and it tries to create the plugins directory for in case it doesn't exists.
The error suggests that you already have a plugins file inside the ~/.sbt/1.0/ directory, can you check whether this is true?
I'm saying this because Metals uses java.nio.file.Files.createDirectory, which should according to the documentation throws a FileAlreadyExistsException in this case:
if a directory could not otherwise be created because a file of that name already exists
Yes I already have that directory, although it is a symbolic link to elsewhere on the filesystem.
Got it, then it seems you're hitting this https://bugs.openjdk.java.net/browse/JDK-8130464
The createDirectory method is throwing because a symlink is a file, ignoring the fact that it's pointing to a directory.
I can work on a patch for this specific case.
Most helpful comment
Got it, then it seems you're hitting this https://bugs.openjdk.java.net/browse/JDK-8130464
The
createDirectorymethod is throwing because a symlink is a file, ignoring the fact that it's pointing to a directory.I can work on a patch for this specific case.