-
-
Notifications
You must be signed in to change notification settings - Fork 219
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
Getting Started Repl doesnt start on WIndows w/ Oracle Java 15 and 16 #1162
Comments
Thanks for the report. |
Not sure I would label this a There are many layers to this. And some of those are unknown (at least to me), making it extremely difficult. For instance, it is unclear to me how the shell being used is determined. A while back I changed from using the Clojure CLI to (With Leiningen we use a I am unsure what the ratio is between Windows machines where it is working and where it is not. Maybe it is 90/10, maybe something else... Everytime I try to fix this it seems to be improved (but what do I know), but also does not nail it 100%. The sample size is not big since most Windows users are wise enough to use WSL for development work. Neither the Getting Started REPL nor the Standalone REPL can assume WSL. They need to work with the least common denominator. I might give up on this pipe dream at some point, and just tell Windows users that if the Getting Started REPL works, celebrate, and otherwise point them at some longer path to get to test the Clojure REPL plugged to the editor. But I am not there yet. (Probably should figure out how to inform about the longer path meanwhile, but anyway). There are at least two parameters to the puzzle that I know of.
The The current command line, let's denote it A:
Despite not really having the time for this now I just conducted some experiments. B:
I think this indicates that OnMyMachine PowerShell is used when C:
So, now maybe that indicates the command is being run through the CMD shell after all? At least OnMyMachine... What about other people's machines? I'm stuck for now. Maybe I should try with a |
You can diagnose how CLI args get passed through to Clojure command line args like this with babashka: bb -e "*command-line-args*" -- 1 2 3
("1" "2" "3") E.g. in cmd.exe:
In Powershell:
I don't understand what cmd.exe and Powershell have to do with this if you are launching the process from NodeJS. The shell isn't involved in that case. PS: you can install babashka on Windows easily with scoop: |
Thanks!
I don't really understand this, as must be obvious from my comment above. But something is interpreting the command line and needs quoting of some kind. And it seems that this something is different on different machines. Also I want the command line echoed to work if the user copies it and pastes it on the prompt. In which case it is good to know which kind of prompt. And, since the I'll try that trick of yours now... |
From https://nodejs.org/api/child_process.html#child_process_spawning_bat_and_cmd_files_on_windows:
Since you are launching |
FWIW, this older clj-kondo plugin for VSCode ran the clj-kondo binary in this way: AFAIK it worked cross-platform (and probably still works) |
I don't think we can use |
I think so too. Just haven't succeeded with that yet. Not for lack of trying. |
@PEZ at one point I decided I would figure Windows shell escaping out and started taking notes. |
Thanks @lread . I'll certainly check that out because I have also tried to lay this puzzle and I get dizzy. 😄 |
The quoting problems seems to have been a red herring. In my Windows dev environment I have removed the quoting out of the picture (latest #1164 VSIX also has this build) which worked on that machine until I upgraded Java. So the failure seems to be introduced somewhere between Java 8 and Java 15, I haven't bisected it down further than that right now. Now I am actually stuck again. Can't think of a single thing I can try to make this work. I am hoping som sleep will help. |
I have now tried with Java 12 and the command works then. So the error is then introduced with Java 13, 14 or 15, I guess. Here is some sort of reproduction: From a directory with
Expected: Actual, using Java 12: Actual, using Java 15 and 16:
Now I would want to try this with the Clojure CLI as well, but I can't get that to work on my Windows machine. So if someone with the Clojure CLI working on Windows could try this that would be awesome. (Just replace NB: Not that Clojure CLI is an option for the Getting Started REPL, which only requires Java. It is for trying to locate where the error happens. |
Removed some confusing comments. It seems that even if |
And now I think I have confirmed that the error seems to happen only with the Java 15 and 16 (and possibly earlier versions) installed with Oracle's installer. Using Which does not add any quoting what so ever to the command shelled out on Windows. |
I have tried to test some variations on my machine, since it looks like @stuartstein777 have similar issues. If I run from Windows cmd it works, on all versions of java that I have. Here with Java 16: C:\Users\stian\AppData\Local\Temp\betterthantomorrow.calva\ur5dk.calva>java -jar deps.clj.jar -Sdeps "{:deps {nrepl/nrepl {:mvn/version,""0.8.3""},cider/cider-nrepl {:mvn/version,""0.26.0""}}}" -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" Here with Java 11: C:\Users\stian\AppData\Local\Temp\betterthantomorrow.calva\ur5dk.calva>java -jar deps.clj.jar -Sdeps "{:deps {nrepl/nrepl {:mvn/version,""0.8.3""},cider/cider-nrepl {:mvn/version,""0.26.0""}}}" -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" And now the Getting started REPL in Calva also works! This one is a proper Heisenbug indeed. What I did was open a powershell in VS Code. There I started the cmd shell and ran the command : After that every combination I have tried has worked. I have set Java 16 in JAVA_HOME and path, and started from cmd. And now it also works in Calva.
Here I have downgraded the nrepl version to see if the download affects something. It didn't. |
Thanks, @stianalmaas ! How does docker and kubernetes fit into your setup? Can you also paste the output from the Jack-in terminal, when it works? |
I have Docker Desktop for Windows installed. Isn't it normal that the nREPL server uses that? Here is what the output looks like when starting up:
|
@PEZ, I haven't been following your attempts and strategies closely, and maybe you have thought of this already but: I wonder if deps.clj could be modified to retrieve its args from a specified generated file rather than the command line. This way you could remove Windows escaping rules from the equation. So maybe you'd have:
Would something like that maybe help? |
@PEZ I also managed to get it working with the Clojure CLI now. For that I have to use Powershell. The trick here was to escape the double-quotes with back-ticks. Like this:
This also works with Java, so it seems everything works no matter what I do...
But maybe it is better to think outside the box as @lread suggests. |
Latest findings is that
Using the command line from https://clojure.atlassian.net/browse/TDEPS-133#icft=TDEPS-133 as an example:
But:
Both experiments need to be run with this setting of PS C:\ ...\bin> $env:JAVA_CMD = ".\java.exe" (No, it doesn't matter if we try with other quoting. It is not related to our quoting.) Note that the Oracle installer installs both these executables. One is fine, the other is not. Problem is that it makes the one not working the default, and that cause the Getting Started REPL to fail. |
Great isolation of the problem! This has been quite a journey that I've been following. |
@lread, I doubt that would help. The args are delivered just fine to java and to deps.clj. |
@PEZ Can you also add to the details whether you set the environment variable |
To check from a REPL which Java version you are running: |
Updated the comment above with info about setting |
Also note that @PEZ could not pass Java properties with the "system" Oracle JDK 16:
I'm not sure what we're dealing with here, it looks like the Oracle JDK 16 wrapper is seriously screwing up command line parsing in multiple ways. Have you included this in the issue Oracle issue @PEZ? If not, I think it warrants another issue. |
This might've been covered by one of the earlier posts in this thread, but this workaround (for a project REPL, not for a getting started REPL — sorry!) works on my colleague's Windows machine: That is, wrap every value in the Value column in double double quotes. Java version:
Output of
|
Thanks, @eerohele Very good to know about this workaround! Just tell your colleague to remember to reset those settings later, because it probably will mess up jack-in to other project types. (And also, already is not following the latest Calva which is using |
Very interesting that it seems to hit also on JDK15. Note to self: I should check if the issue I reported to Oracle is reproducable there as well. |
@PEZ Can you please specify when you mention a Java version, also if this is Oracle or some other vendor's JDK? |
I was mainly quoting from the comment above. But to elaborate some little more on where this seems to live, I've only seen it in the |
Oh, sorry — the workaround above was not for a Getting Started REPL, it's for a project REPL. So it might be a workaround for a different (but maybe related?) issue? Apologies for muddying the waters! |
@eerohele is it a deps.edn project? |
Leiningen. |
@PEZ Can you test the following with the Put some args in a file called
Then run
On macOS JDK 11 (AdoptOpenJDK) I see the output:
If this workaround works, perhaps that will be an escape hatch. Hat tip to @lread for suggesting this. |
There is hope!
|
@PEZ ok nice. So this could be an escape hatch. The only downsize here is that this only works with JDK9+. |
Which is a pretty big downside, but I take what I can get. 😄 |
Maybe Calva can detect the java version first and then apply this trick? |
That's what we will need to do. But I will be happy to do it. I really thought for a while that I was out of options. |
This is the first part of a full solution. Deps.clj will also have to pass its argument to the java subprocess in a similar way. |
The bug has been confirmed by Oracle and is being tracked here: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8266473 They have confirmed it with JDK11 even. I will test it, but my guess is that it is with JDK15 or 16 that the installer wires up the problematic java.exe as system default. |
I can also confirm it with JDK11, actually. I am not super savvy with WIndows, but I managed to uninstall Java 16 and now can do this:
And the Getting Started REPL fails because of this, of course. |
Confirming that 15.0.2 drops "s on my Windows box, whereas java 15.0.1 does not: C:\java\jdk-15.0.1\bin\java.exe PrintArgs.java '"bar"' java.exe PrintArgs.java '"bar"' |
It's actually more peculiar than that, @tallpeak . 😄 Try
|
Perhaps a bit unsurprisingly, we can now confirm that this hits Leiningen jack-in as well. Also for CIDER users: clojure-emacs/cider#2963 |
The bug's been fixed, and they said it's getting put into versions 17 and 18. |
That's good. But really they should put the fix into the JDK11-16 distributions too. |
For those who are struggling to understand this behavior, it might help to understand that Windows itself has no concept of parameters or quoting. In unix/macOS a process is invoked with a list of arguments, and the shell is responsible for parsing a command line to build that list, but for Windows, when a process is invoked it is simply passed the raw command line. It's completely up to the process itself to decide how to interpret that command line as a list of arguments, and so there is no guarantee of consistency between different programs. |
Closing this now. We reported the bug to the Java team and they fixed it, they even back-ported it to Java11-16. It is a bit too involved to create a workaround in Calva. Even if someone put in the work, we would still need to maintain it. |
Issue Type: Bug
Click nREPL in bottom toolbar
Click Fire Up Getting Started REPL
Click Use Existing Directory
repl fails to start with the error in the terminal:
The output window shows
; Jacking in...
; Starting Jack-in Terminal: java -jar ".calva\deps.clj.jar" -Sdeps "{:deps {nrepl/nrepl {:mvn/version,""0.8.3""},cider/cider-nrepl {:mvn/version,""0.25.11""}}}" -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
The terminal, on fail, shows:
java -jar ".calva\deps.clj.jar" -Sdeps "{:deps {nrepl/nrepl {:mvn/version,""0.8.3""},cider/cider-nrepl {:mvn/version,""0.25.11""}}}" -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
Error while parsing option "--config-data {:deps {nrepl/nrepl {:mvn/version,0.8.3},cider/cider-nrepl {:mvn/version,0.25.11}}}": java.lang.NumberFormatException: Invalid number: 0.8.3
Jack-in process exited. Status: 1
Extension version: 2.0.194
VS Code version: Code 1.55.2 (3c4e3df9e89829dce27b7b5c24508306b151f30d, 2021-04-13T09:35:57.887Z)
OS version: Windows_NT x64 10.0.18363
System Info
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
The text was updated successfully, but these errors were encountered: