scala-cli
scala-cli copied to clipboard
scala-cli not working in Windows git bash using sdkman installed java
Version(s) 1.0.4
Describe the bug
Because I am unable to install scala-cli using the unsigned installer or other means I have resorted to sdkman.
sdkman mostly works on Windows using Git Bash. scala-cli seems that is trying to use windows path (see To Reproduce section) versus UNIX like path which would be as follows:
/c/Users/<id>/.sdkman/candidates/java/current/bin/java
This works.
$ /c/Users/<id>/.sdkman/candidates/java/current/bin/java --version
openjdk 17.0.8.1 2023-08-24
OpenJDK Runtime Environment Temurin-17.0.8.1+1 (build 17.0.8.1+1)
OpenJDK 64-Bit Server VM Temurin-17.0.8.1+1 (build 17.0.8.1+1, mixed mode, sharing)
To Reproduce
Note: when installing the final copy step fails so you need to do the final copy and rename of sdkman install of each component. symlink current does work after the copy as seen above.
Install git bash Install sdkman Install java 17 using sdkman install scala-cli
MINGW64 ~
$ scala-cli
Error: java.io.IOException: Cannot run program "C:\Users\<id>\.sdkman\candidates\java\current\bin\java.exe" (in directory "C:\Users\<id>"): CreateProcess error=2, The system cannot find the file specified
For more details, please see 'C:\Users\<id>\.scala-build\stacktraces\1697581457-16503185580896253402.log'
Expected behaviour
Would like scala-cli to work in git bash.
scala-cli will run in both command shell and power shell although the coloring does not work well in powershell.
In Command window and Power Shell it will work using another Java in the path. Can't use current link in that case.
>where java
C:\Users\<id>\apps\jdk17.0.8_8\bin\java.exe
>c:\Users\<id>\.sdkman\candidates\scalacli\1.0.4\bin\scala-cli
Welcome to Scala 3.3.0 (17.0.8.1, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> 1+1
val res0: Int = 2
Update:
I am using sbt/java/scala-cli via git bash on windows. When I try to use scala-cli it can't find my java. I am wondering if the path separators are causing problems. When I do the outputted command it works.
$ scala-cli`
...
Downloaded https://repo1.maven.org/maven2/org/scala-lang/scala3-sbt-bridge/3.4.2/scala3-sbt-bridge-3.4.2.jar
Error: java.io.IOException: Cannot run program "C:\Users\<user>\.sdkman\candidates\java\current\bin\java.exe" (in directory "C:\Users\<user>"): CreateProcess error=2, The system cannot find the file specified
For more details, please see 'C:\Users\<user>\.scala-build\stacktraces\1717621793-3759065945745879396.log'
$ "C:\Users\<user>\.sdkman\candidates\java\current\bin\java.exe" --version
openjdk 17.0.8.1 2023-08-24
OpenJDK Runtime Environment Temurin-17.0.8.1+1 (build 17.0.8.1+1)
OpenJDK 64-Bit Server VM Temurin-17.0.8.1+1 (build 17.0.8.1+1, mixed mode, sharing)
Maybe use the env var MSYSTEM_PREFIX=mingw64 to prepare the Java path?
Or escape double quote the path to preserve the backslashes. This is all speculation but maybe some ideas for someone familiar with the code base.
Path is reported as /C/User/... in the PATH env var or when using which java unlike the normal windows path listed above.
If the path is not quoted you get the following so this could be a hint:
$ C:\Users\<user>\.sdkman\candidates\java\current\bin\java.exe
bash: C:Users<user>.sdkmancandidatesjavacurrentbinjava.exe: command not found