sbt / sbt

sbt, the interactive build tool
https://scala-sbt.org
Apache License 2.0
4.81k stars 937 forks source link

Launcher problems with JDK 11? #6793

Closed tobyweston closed 2 years ago

tobyweston commented 2 years ago

Does this line have a problem with newer versions of Java?

https://github.com/sbt/launcher/blob/605b67814f4f1a2ed6ddd46213ffec8e8e58ec2e/launcher-implementation/src/main/scala/xsbt/boot/Find.scala#L60

I get the following against

java.lang.IllegalArgumentException: URI scheme is not "file"
at java.base/java.io.File.<init>(File.java:423)
at xsbt.boot.ResolvePaths$.apply(Find.scala:60)
at xsbt.boot.ResolvePaths$.$anonfun$apply$3(Find.scala:54)
at scala.Option.map(Option.scala:242)
at xsbt.boot.IvyOptions.map(LaunchConfiguration.scala:116)
at xsbt.boot.LaunchConfiguration.map(LaunchConfiguration.scala:78)
at xsbt.boot.ResolvePaths$.apply(Find.scala:54)
at xsbt.boot.Find.apply(Find.scala:45)
at xsbt.boot.Find$.apply(Find.scala:13)
at xsbt.boot.Launch$.parseConfiguration(Launch.scala:110)
at xsbt.boot.Launch$.parseAndInitializeConfig(Launch.scala:104)
at xsbt.boot.Launch$.apply(Launch.scala:33)
at xsbt.boot.Launch$.apply(Launch.scala:21)
at xsbt.boot.Boot$.runImpl(Boot.scala:78)
at xsbt.boot.Boot$.run(Boot.scala:73)
at xsbt.boot.Boot$.main(Boot.scala:21)
at xsbt.boot.Boot.main(Boot.scala)
[error] [launcher] error during sbt launcher: java.lang.IllegalArgumentException: URI scheme is not "file"

Massive guess from me. I'm running from within IDEA 2021.3.1 (which doesn't let me start the IDE in anything less than JDK 11). I'm speculating that something has changed in Java's File to require a scheme... the line above does explicitly set it to null...

https://github.com/sbt/launcher/blob/605b67814f4f1a2ed6ddd46213ffec8e8e58ec2e/launcher-implementation/src/main/scala/xsbt/boot/Find.scala#L59

IntelliJ IDEA 2021.3.1 (Ultimate Edition)
Build #IU-213.6461.79, built on December 28, 2021
Runtime version: 11.0.13+7-b1751.21 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.1
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 8
Registry:
    scala.erase.compiler.process.jdk.once=false

Non-Bundled Plugins:
    org.nik.presentation-assistant (1.0.9)
    net.seesharpsoft.intellij.plugins.csv (2.18.2)
    name.kropp.intellij.makefile (213.5744.224)
    com.intellij.plugins.macoskeymap (213.5744.3)
    com.intellij.ideolog (203.0.27.0)
    org.jetbrains.plugins.hocon (2021.1.0)
    intellij.haskell (1.0.0-beta88)
    com.bashorov.mainMenuToggler (0.2.1)
    org.intellij.scala (2021.3.18)
    com.haulmont.jpab (2021.6.2-213)
eed3si9n commented 2 years ago

Thanks for the report. Could you provide reproduction steps so we can reproduce your problem on our computers? We run CI for sbt using JDK 8 and JDK 17 currently, and it used to be tested on JDK 11 for a long time.

tobyweston commented 2 years ago

it's very odd, so apologies but I can't reproduce on other PCs... but

  1. Select New Project from the Welcome to Intellij IDEA screen (or if a project is open, File > New Project)
  2. Select Scala and sbt, hit Next
  3. Create the project (JDK 11.0.12, SBT 1.6.2, Scala 2.13.8), click Finish

Project will initialise but immediately fail with the error above. All my Scala projects seem to do this now 😢

Its on a new Mac (which is variable here - I'm fresh install everything). Its Monterey 12.1, MBP 13' 2020 on Apple M1.

Let me know if you have any thoughts, I'm really sorry this sounds flakey but have exhausted my debugging/experimenting (changed various settings above for example). I can't run IDEA itself on Java 8 (the particular versions restricts to 11).

It's similar to https://youtrack.jetbrains.com/issue/SCL-19190 and in fact, I raised it with IntelliJ at https://youtrack.jetbrains.com/issue/SCL-19883

eed3si9n commented 2 years ago

Could you try reproducing the problem without involving IntelliJ and launching sbt using the official sbt runner (available from https://www.scala-sbt.org/download.html) and JDK built for M1 Macs (for example Temurin 11 https://adoptium.net/releases.html?variant=openjdk11&jvmVariant=hotspot)?

tobyweston commented 2 years ago

I'm having trouble setting up without IDEA in the mix, suggest we close this issue for now and I'll work with IntelliJ in #SCL-19883 and feedback here if I get anywhere. Thanks for all the help (and SBT and awesome contribs to the community)

tobyweston commented 2 years ago

Update: I'm in idiot.

I was passing windows specific paths to SBT. So, without IntelliJ in the mix, if I run...

sbt -Dsbt.ivy.home=C:/Users/toby/.ivy

(Which I accidentally inherited when sharing IntelliJ settings between Windows and Mac), I get the error,

bash-3.2$ sbt -Dsbt.ivy.home=C:/Users/toby/.ivy
java.lang.IllegalArgumentException: URI scheme is not "file"
    at java.base/java.io.File.<init>(File.java:423)
    at xsbt.boot.ResolvePaths$.apply(Find.scala:60)
    at xsbt.boot.ResolvePaths$.$anonfun$apply$3(Find.scala:54)
    at scala.Option.map(Option.scala:242)
    at xsbt.boot.IvyOptions.map(LaunchConfiguration.scala:116)
    at xsbt.boot.LaunchConfiguration.map(LaunchConfiguration.scala:78)
    at xsbt.boot.ResolvePaths$.apply(Find.scala:54)
    at xsbt.boot.Find.apply(Find.scala:45)
    at xsbt.boot.Find$.apply(Find.scala:13)
    at xsbt.boot.Launch$.parseConfiguration(Launch.scala:110)
    at xsbt.boot.Launch$.parseAndInitializeConfig(Launch.scala:104)
    at xsbt.boot.Launch$.apply(Launch.scala:33)
    at xsbt.boot.Launch$.apply(Launch.scala:21)
    at xsbt.boot.Boot$.runImpl(Boot.scala:78)
    at xsbt.boot.Boot$.run(Boot.scala:73)
    at xsbt.boot.Boot$.main(Boot.scala:21)
    at xsbt.boot.Boot.main(Boot.scala)
[error] [launcher] error during sbt launcher: java.lang.IllegalArgumentException: URI scheme is not "file"

So I guess the error message was throwing me (URI scheme is not file when passing in invalid 'File' paths).

🤦