-
Notifications
You must be signed in to change notification settings - Fork 937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sbt doesn't recognise WSL UNC path - Invalid build URI (no handler available) #7135
Comments
Looks like this is due to JDK's misdesign: https://bugs.openjdk.org/browse/JDK-4723726 Suggested JDK's workaround is to use |
Fix for diff --git a/io/src/main/scala/sbt/io/IO.scala b/io/src/main/scala/sbt/io/IO.scala
index 5c0e114..ac635f8 100644
--- a/io/src/main/scala/sbt/io/IO.scala
+++ b/io/src/main/scala/sbt/io/IO.scala
@@ -1151,7 +1151,7 @@ object IO {
*/
def directoryURI(dir: File): URI = {
assertAbsolute(dir)
- directoryURI(dir.toURI.normalize)
+ directoryURI(dir.toPath.normalize.toUri)
}
/**
@@ -1162,13 +1162,18 @@ object IO {
def directoryURI(uri: URI): URI = {
if (!uri.isAbsolute) return uri; //assertAbsolute(uri)
val str = uri.toASCIIString
+
+ if (uri.getScheme != FileScheme) {
+ uri.normalize()
+ }
+
val dirURI =
- if (str.endsWith("/") || uri.getScheme != FileScheme || (uri.getRawFragment ne null))
+ if (str.endsWith("/") || (uri.getRawFragment ne null))
uri
else
new URI(str + "/")
- dirURI.normalize
+ new File(dirURI).toPath.normalize.toUri
}
private[sbt] val isWindows: Boolean =
diff --git a/io/src/main/scala/sbt/io/Path.scala b/io/src/main/scala/sbt/io/Path.scala
index b1d6c65..e45fd91 100644
--- a/io/src/main/scala/sbt/io/Path.scala
+++ b/io/src/main/scala/sbt/io/Path.scala
@@ -291,7 +291,7 @@ object Path extends Mapper {
def fileProperty(name: String): File = new File(System.getProperty(name))
def userHome: File = fileProperty("user.home")
- def absolute(file: File): File = new File(file.toURI.normalize).getAbsoluteFile
+ def absolute(file: File): File = new File(file.toPath.normalize.toUri).getAbsoluteFile
def makeString(paths: Seq[File]): String = makeString(paths, File.pathSeparator)
def makeString(paths: Seq[File], sep: String): String = {
val separated = paths.map(_.getAbsolutePath) |
Thanks for the really detailed bug report! I had tried the patch and it is working for sbt 1.10.4! Without the patch I got the exact same stacktrace as you.
|
steps
Start
sbt-laucher.jar
with a current UNC WSL directory, for example (starting from NuShell, because cmd.exe doesn't support UNC paths well):problem
Sbt fails.
expectation
Sbt doesn't fail.
notes
JetBrains IDEA seems to work fine with WSL UNC paths, and quick research shows that Java supports UNC paths since the year 1999, so I'm guessing it's something in Sbt's logic?
The text was updated successfully, but these errors were encountered: