From e4fd8602ac12b5baf8b13251956b2d5da1a47cf1 Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Mon, 28 Aug 2023 19:50:03 +0200 Subject: [PATCH] bugfix: Don't use cache directory with `null` in it's path This is a bug in ProjectDirectories, which seems to be super hard to fix, so instead we can special case it. This is not super important to use that directory anyway, we fall back to local workspace. Fixes https://github.com/scalameta/metals/issues/5590 --- .../src/main/scala/scala/meta/internal/metals/Trace.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/metals/src/main/scala/scala/meta/internal/metals/Trace.scala b/metals/src/main/scala/scala/meta/internal/metals/Trace.scala index a72855c7d0f..481aebe170a 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Trace.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Trace.scala @@ -26,8 +26,12 @@ object Trace { // the path making it difficult to tail/cat from the terminal and cmd+click from VS Code. // Instead, we use the `cacheDir` which has no spaces. The logs are safe to remove so // putting them in the "cache directory" makes more sense compared to the "config directory". - AbsolutePath(projectDirectories.cacheDir) - }.toOption + val cacheDir = projectDirectories.cacheDir + // deal with issue on windows and PowerShell, which would cause us to create a null directory in the workspace + if (cacheDir.startsWith("null/")) + None + else Some(AbsolutePath(cacheDir)) + }.toOption.flatten private val localDirectory: AbsolutePath = PathIO.workingDirectory.resolve(".metals/")