This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-05-02
Channels
- # announcements (31)
- # babashka (19)
- # beginners (90)
- # biff (1)
- # calva (172)
- # cider (3)
- # cljsrn (3)
- # clojure (84)
- # clojure-australia (1)
- # clojure-europe (11)
- # clojurescript (48)
- # css (1)
- # data-science (9)
- # datalog (3)
- # emacs (16)
- # events (2)
- # fulcro (8)
- # jackdaw (31)
- # luminus (3)
- # malli (3)
- # off-topic (13)
- # onyx (3)
- # random (1)
- # remote-jobs (2)
- # shadow-cljs (88)
- # vim (1)
- # xtdb (13)
I would like to try this with the Clojure CLI tools as well, but for some reason clojure
does not work on this windows machine of mine.
Error: Could not find or load main class clojure.main
Caused by: java.lang.ClassNotFoundException: clojure.main
I added some more detail, and a repro, as a comment on the issue. https://github.com/BetterThanTomorrow/calva/issues/1162#issuecomment-830765259
Which was not entirely true. I could only run it in the same shell I had installed it in. It reported the right version but something else is going on. Installing java 16 and running the command from a new shell exposes the error.
Then again. Clean install of adopt16-hotspot now, removed all Oracle things from the PATH and restarted the machine. It works still. So maybe it is an issue only happening with the Java 15/16 installed with the Oracle installer.
using clojure CLI in powershell on my machine
❯ clojure -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]"
Error while parsing option "--config-data {:deps {nrepl/nrepl {:mvn/version,0.8.3},cider/cider-nrepl {:mvn/version,0.26.0}}}": java.lang.NumberFormatException: Invalid number: 0.8.3
yeah, dont think it will work with cmd, I think clojure CLI installs itself a ps module
@qmstuart Your -Sdeps string is not valid. You should escape the inner strings with \"
(instead of ""
)
Yeah, you can of course try with PS command line:
clojure -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]'
❯ clojure -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]'
Error while parsing option "--config-data {:deps {nrepl/nrepl {:mvn/version,0.8.3},cider/cider-nrepl {:mvn/version,0.26.0}}}": java.lang.NumberFormatException: Invalid number: 0.8.3
That is exactly the same as you get if you use java -jar .calva\deps.clj.jar
instead, right?
@U04V15CAJ, @U064X3EF3 it seems that with both clojure
and deps.clj
we get the results that the argument parsing breaks if using the java 15 installed with Oracles windows installer and that it does not break with earlier java and neither with java 15 if installing, say adopt15-hotspot
with scoop.
We get the same error/working for the same java versions if the command is spawned from nodejs without any quoting of the arguments.
I’m unfamiliar with where this parsing fails. It is peculiar that it is the exact same message, regardless of launcher.
Same result If I use the PS command line from https://clojure.atlassian.net/browse/TDEPS-133#icft=TDEPS-133 Oracle Java 16:
java -jar deps.clj.jar -Sdeps '{:deps {viebel/klipse-repl {:mvn/version ""0.2.3""}}}' -m klipse-repl.main
Error while parsing option "--config-data {:deps {viebel/klipse-repl {:mvn/version 0.2.3}}}": java.lang.NumberFormatException: Invalid number: 0.2.3
Adopt OpenJDK 15:
java -jar .calva\deps.clj.jar -Sdeps '{:deps {viebel/klipse-repl {:mvn/version ""0.2.3""}}}' -m klipse-repl.main
...
Welcome to Klipse REPL (Read-Eval-Print Loop)
Clojure 1.10.3
user=>
@U0ETXRFEW Try:
java -jar deps.clj.jar -Sdeps '{:deps {viebel/klipse-repl {:mvn/version \"0.2.3\"}}}' -m klipse-repl.main
in powershell
This is what worked for me (on other version of Java, I haven't got Java 16)That’s what is used in TS. Same results. But I can humour you with this one, if you like.
java -jar deps.clj.jar -Sdeps '{:deps {viebel/klipse-repl {:mvn/version \"0.2.3\"}}}' -m klipse-repl.main
Error while parsing option "--config-data {:deps {viebel/klipse-repl {:mvn/version 0.2.3}}}": java.lang.NumberFormatException: Invalid number: 0.2.3
Haven’t tried. I expect same results. And I have no use for execFile in Getting Started REPL. I can of course try it, if we think it would tell us something.
> And I have no use for execFile in Getting Started REPL
I've tried to communicate multiple times that I think that this is the preferred way of invoking java
from nodeJS, as there is nothing in between
It is a 99.999% guarantee we have the same results with execFile. I will now try it anyway, because if it works, maybe I can hack something around it.
I think I understand the difference, execFile
waits for the process to end, while spawn
keeps it running, perhaps?
as in, execFile
is similar to clojure.java.shell/sh
where spawn
is more similar to babashka.process/process
So spawn
without the shell option would then be the most reliable way without running into shell-specific quoting issues
I see there have been some changes for Windows here: https://github.com/openjdk/jdk/commit/e56e087290dc1fef5d7ba88ec1e955cb49dbce14
Another commit in this area: https://github.com/openjdk/jdk/commit/5a98b8cfb0cd4c5ce84746e9fa5e42a86d1b2d24#diff-71e1dde85b2937bbf08d0bfd9e8a2e3553c578a3f58907ba6f4f30ec350db184
Etc. etc. So they may have changed something which doesn't require any additional fixes from the deps.clj side, or something
From 15. Even if I haven’t confirmed that myself. But @qmstuart or @U06H8MQER was using that.
And not with AdoptJDK but only Oracle? Can you get these details verified more precisely?
I should try it with Oracle Java 15 as well. And confirm that I have tested with adopt 16, (I think I did, but I have tested so many things now…)
I also think I have tried with oracle’s openjdk installed with scoop and that didn’t have the problem. That I can test again now, quickly.
Let me try this:
(and windows? (not (System/getenv "DEPS_CLJ_NO_WINDOWS_FIXES")))
would this work for you?But let’s try Oracles openjdk scooped first. Unless you think the changes you have seen there are only applied to the one installed via the regular installer.
I mean, I will introduce this env var, just for our process of debugging this issue and it will probably be removed thereafter once we find a proper fix
@U0ETXRFEW Try this one: https://1157-230101668-gh.circle-artifacts.com/0/release/deps.clj-0.0.15-SNAPSHOT-standalone.jar and set the env var
So far so good:
C:\Users\borkdude\Downloads\jdk-16.0.1+9>bin\java.exe -jar %USERPROFILE%\Downloads\deps.clj-0.0.15-SNAPSHOT-standalone.jar
Clojure 1.10.1
user=>
C:\Users\borkdude\Downloads\jdk-16.0.1+9>bin\java.exe -jar %USERPROFILE%\Downloads\deps.clj-0.0.15-SNAPSHOT-standalone.jar --version
Clojure CLI version (deps.clj) 1.10.3.822
C:\Users\borkdude\Downloads\jdk-16.0.1+9>bin\java.exe -jar %USERPROFILE%\Downloads\deps.clj-0.0.15-SNAPSHOT-standalone.jar -Sdeps "{:deps {med
ley/medley {:mvn/version """1.3.0"""}}}"
Clojure 1.10.3
user=> (require '[medley.core :as medley])
nil
Powershell:
PS C:\Users\borkdude\Downloads\jdk-16.0.1+9> bin\java.exe -jar C:\Users\borkdude\Downloads\deps.clj-0.0.15-SNAPSHOT-standalone.jar -Sdeps '{:deps {medley/medley {:mvn/version \"1.3.0\"}}}'
Clojure 1.10.3
user=> (require '[medley.core :as medley])
nil
PS C:\Users\borkdude\Downloads\jdk-16.0.1+9> bin\java.exe -jar C:\Users\borkdude\Downloads\deps.clj-0.0.15-SNAPSHOT-standalone.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]'
Downloading: cider/cider-nrepl/0.26.0/cider-nrepl-0.26.0.pom from clojars
Downloading: cider/cider-nrepl/0.26.0/cider-nrepl-0.26.0.jar from clojars
nREPL server started on port 65065 on host kubernetes.docker.internal -
PS C:\Users\borkdude\Downloads\jdk-16.0.1+9> bin\java.exe -jar C:\Users\borkdude\Downloads\deps.clj-0.0.15-SNAPSHOT-standalone.jar -Sdeps '{:deps {viebel/klipse-repl {:mvn/version \"0.2.3\"}}}' -m klipse-repl.main
Welcome to Klipse REPL (Read-Eval-Print Loop)
Clojure 1.10.3
user=>
I’m not sure I am doing it right, but I get the same result with the new jar and the flag set.
PS C:\Users\Peter Strömberg\AppData\Local\Temp\betterthantomorrow.calva\jfj0p3> $env:DEPS_CLJ_NO_WINDOWS_FIXES = "true"
PS C:\Users\Peter Strömberg\AppData\Local\Temp\betterthantomorrow.calva\jfj0p3> echo $DEPS_CLJ_NO_WINDOWS_FIXES
PS C:\Users\Peter Strömberg\AppData\Local\Temp\betterthantomorrow.calva\jfj0p3> echo $env:DEPS_CLJ_NO_WINDOWS_FIXES
true
PS C:\Users\Peter Strömberg\AppData\Local\Temp\betterthantomorrow.calva\jfj0p3> cd .calva
PS C:\Users\Peter Strömberg\AppData\Local\Temp\betterthantomorrow.calva\jfj0p3\.calva> java -jar deps.clj.jar -Sdeps '{:deps {viebel/klipse-repl {:mvn/version \"0.2.3\"}}}' -m klipse-repl.main
Error while parsing option "--config-data {:deps {viebel/klipse-repl {:mvn/version 0.2.3}}}": java.lang.NumberFormatException: Invalid number: 0.2.3
PS C:\Users\Peter Strömberg\AppData\Local\Temp\betterthantomorrow.calva\jfj0p3\.calva>
Ah, wait, deps.clj invoked a different java binary probably then the one I ran deps.clj with :)
C:\Users\borkdude\Downloads\jdk-16.0.1>bin\java.exe -jar C:\Users\borkdude\Downloads\deps.clj-0.0.15-SNAPSHOT-standalone.jar
Clojure 1.10.1
user=> (System/getProperty "java.version")
"16.0.1"
user=> (System/getProperty "java.vendor")
"Oracle Corporation"
Right now I am at a situation where I don’t know how to make Windows use anything else then the Oracle installed Java 16.
I avoid this by not using installers, but just download the zip archive and start java manually
works with Oracle 16:
C:\Users\borkdude\Downloads\jdk-16.0.1>bin\java.exe -jar %USERPROFILE%\Downloads\deps.clj-0.0.15-SNAPSHOT-standalone.jar -Sdeps "{:deps {medley/medley {:mvn/version """1.3.0"""}}}"
Clojure 1.10.3
user=> (System/getProperty "java.version")
"16.0.1"
user=> (System/getProperty "java.vendor")
"Oracle Corporation"
Also works with AdoptOpenJDK 16:
C:\Users\borkdude\Downloads\jdk-16.0.1+9>bin\java.exe -jar %USERPROFILE%\Downloads\deps.clj-0.0.15-SNAPSHOT-standalone.jar -Sdeps "{:deps {medley/medley {:mvn/version """1.3.0"""}}}"
Clojure 1.10.3
user=> (System/getProperty "java.vendor")
"AdoptOpenJDK"
user=> (System/getProperty "java.version")
"16.0.1"
PS C:\Program Files\Java\jdk-16.0.1\bin> .\java.exe -jar .\deps.clj.jar -Sdeps '{:deps {viebel/klipse-repl {:mvn/version \"0.2.3\"}}}' -m klipse-repl.main
Welcome to Klipse REPL (Read-Eval-Print Loop)
Clojure 1.10.3
user=>
@U0ETXRFEW You need to set the environment variable JAVA_CMD
This:
PS C:\Program Files\Java\jdk-16.0.1\bin> java -jar .\deps.clj.jar -Sdeps '{:deps {viebel/klipse-repl {:mvn/version \"0.2.3\"}}}' -m klipse-repl.main
Error while parsing option "--config-data {:deps {viebel/klipse-repl {:mvn/version 0.2.3}}}": java.lang.NumberFormatException: Invalid number: 0.2.3
PS C:\Program Files\Java\jdk-16.0.1\bin> java -version
java version "16.0.1" 2021-04-20
Java(TM) SE Runtime Environment (build 16.0.1+9-24)
Java HotSpot(TM) 64-Bit Server VM (build 16.0.1+9-24, mixed mode, sharing)
But if I run the java command as it is resolved after having used Oracle’s installer, it doesn’t work.
@U0ETXRFEW That problem can be solved like this: https://github.com/marcomorain/clojure-lint/blob/86f699258d7478d44237241ecf1f0be914170887/src/extension.ts#L48
If you type where java
in cmd.exe, which one do you see? it might be some .bat file that Oracle has put there
Powershell reports this one C:\Program Files\Common Files\Oracle\Java\javapath\java.exe
which I will now try before I hack Calva around this thing. 😃
PS C:\Program Files\Common Files\Oracle\Java\javapath> .\java.exe -jar .\deps.clj.jar -Sdeps '{:deps {viebel/klipse-repl {:mvn/version \"0.2.3\"}}}' -m klipse-repl.main
Error while parsing option "--config-data {:deps {viebel/klipse-repl {:mvn/version 0.2.3}}}": java.lang.NumberFormatException: Invalid number: 0.2.3
PS C:\Program Files\Common Files\Oracle\Java\javapath>
I hadn’t. But
PS C:\Program Files\Common Files\Oracle\Java\javapath> $env:JAVA_CMD = ".\java.exe"
PS C:\Program Files\Common Files\Oracle\Java\javapath> .\java.exe -jar .\deps.clj.jar -Sdeps '{:deps {viebel/klipse-repl {:mvn/version \"0.2.3\"}}}' -m klipse-repl.main
Error while parsing option "--config-data {:deps {viebel/klipse-repl {:mvn/version 0.2.3}}}": java.lang.NumberFormatException: Invalid number: 0.2.3
PS C:\Program Files\Common Files\Oracle\Java\javapath>
PS C:\Program Files\Common Files\Oracle\Java\javapath> java -version
java version "16.0.1" 2021-04-20
Java(TM) SE Runtime Environment (build 16.0.1+9-24)
Java HotSpot(TM) 64-Bit Server VM (build 16.0.1+9-24, mixed mode, sharing)
PS C:\Program Files\Common Files\Oracle\Java\javapath>
PS C:\Program Files\Common Files\Oracle\Java\javapath> .\java.exe -version
java version "16.0.1" 2021-04-20
Java(TM) SE Runtime Environment (build 16.0.1+9-24)
Java HotSpot(TM) 64-Bit Server VM (build 16.0.1+9-24, mixed mode, sharing)
PS C:\Program Files\Common Files\Oracle\Java\javapath>
and with this jar: https://1157-230101668-gh.circle-artifacts.com/0/release/deps.clj-0.0.15-SNAPSHOT-standalone.jar
Can I get the version of the deps.clj.jar somehow? I don’t know which version I have put thhere.
Hmmm
PS C:\Program Files\Common Files\Oracle\Java\javapath> $env:DEPS_CLJ_NO_WINDOWS_FIXES = "true"
PS C:\Program Files\Common Files\Oracle\Java\javapath> .\java.exe -jar .\deps.clj.jar -Sdeps '{:deps {viebel/klipse-repl {:mvn/version \"0.2.3\"}}}' -m klipse-repl.main
PS C:\Program Files\Common Files\Oracle\Java\javapath>
Either use '
and "
, or "
and \"
. Both of the following should work:
clojure -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]'
clojure -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]'
ah, it seems to be a powershell specific issue. Can you try the following?
clojure -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]"
@qmstuart, I seriously doubt it is a quoting issue. It will probably start to work if you install some other Java, like scoop install adopt11-hotspot
and then make sure Windows is using it (which might take removing Oracle java from the system PATH).
Everything works as expected on my Windows machine with Java 16.0.1
Note that I don't use backticks like @pavlos but I quote as '{:deps {... {:mvn/version \"...\"}}}'
in Powershell and in cmd.exe
I escape double quotes with triple double quotes:
"{:deps {... {:mvn/version """..."""}}}"
works with Oracle 16:
C:\Users\borkdude\Downloads\jdk-16.0.1>bin\java.exe -jar %USERPROFILE%\Downloads\deps.clj-0.0.15-SNAPSHOT-standalone.jar -Sdeps "{:deps {medley/medley {:mvn/version """1.3.0"""}}}"
Clojure 1.10.3
user=> (System/getProperty "java.version")
"16.0.1"
user=> (System/getProperty "java.vendor")
"Oracle Corporation"
Also works with AdoptOpenJDK 16:
C:\Users\borkdude\Downloads\jdk-16.0.1+9>bin\java.exe -jar %USERPROFILE%\Downloads\deps.clj-0.0.15-SNAPSHOT-standalone.jar -Sdeps "{:deps {medley/medley {:mvn/version """1.3.0"""}}}"
Clojure 1.10.3
user=> (System/getProperty "java.vendor")
"AdoptOpenJDK"
user=> (System/getProperty "java.version")
"16.0.1"
I cannot reproduce any of the issues with any JDK, Oracle or not. Feel free to reach out if you have some new information.
Latest findings regarding Getting Started REPL problems on Windows: https://github.com/BetterThanTomorrow/calva/issues/1162#issuecomment-830857709
Does the Oracle installer set any environment variables on Windows? (that you could detect and perhaps figure out an alternative path to set for the CLI finding Java)
I think it does. Even if it is a bit unclear because right now on my test machine, I have no such environment variables that I can see, yet it is Oracle’s java that is used even though I try to scoop reset
like crazy.
In cmd.exe
, the set
command...
You can get an individual value with set foo
:
C:\Users\seanc>set PROMPT
PROMPT=$P$G
C:\Users\seanc>set
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\seanc\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=DESKTOP-30ICA76
ComSpec=C:\WINDOWS\system32\cmd.exe
DriverData=C:\Windows\System32\Drivers\DriverData
HOMEDRIVE=C:
HOMEPATH=\Users\seanc
Thanks!
C:\Program Files\Common Files\Oracle\Java\javapath>set
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Peter Strömberg\AppData\Roaming
CLIENTNAME=pez
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=PC
ComSpec=C:\Windows\system32\cmd.exe
DEPS_CLJ_NO_WINDOWS_FIXES=true
DriverData=C:\Windows\System32\Drivers\DriverData
HOMEDRIVE=C:
HOMEPATH=\Users\Peter Strömberg
JAVA_CMD=.\java.exe
JAVA_HOME=C:\Users\Peter Strömberg\scoop\apps\adopt16-hotspot\current
LOCALAPPDATA=C:\Users\Peter Strömberg\AppData\Local
LOGONSERVER=\\PC
NUMBER_OF_PROCESSORS=2
OneDrive=C:\Users\Peter Strömberg\OneDrive
OS=Windows_NT
Path=C:\Program Files\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Intel\TXE Components\DAL\;C:\Program Files (x86)\Intel\TXE Components\DAL\;C:\Program Files\Git\cmd;C:\Users\Peter Strömberg\scoop\apps\adopt16-hotspot\current\bin;C:\Users\Peter Strömberg\scoop\apps\openjdk\current\bin;C:\Users\Peter Strömberg\scoop\apps\adopt15-hotspot\current\bin;C:\Users\Peter Strömberg\scoop\apps\adopt14-hotspot\current\bin;C:\Users\Peter Strömberg\scoop\apps\adopt13-hotspot\current\bin;C:\Users\Peter Strömberg\scoop\apps\adopt12-hotspot\current\bin;C:\Users\Peter Strömberg\deps.clj;C:\Users\Peter Strömberg\scoop\apps\nodejs\current\bin;C:\Users\Peter Strömberg\scoop\apps\nodejs\current;C:\Users\Peter Strömberg\scoop\apps\adoptopenjdk-lts-hotspot\current\bin;C:\Users\Peter Strömberg\scoop\shims;C:\Users\Peter Strömberg\AppData\Local\Microsoft\WindowsApps;C:\Users\Peter Strömberg\AppData\Local\Programs\Microsoft VS Code\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 122 Stepping 8, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=7a08
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Users\Peter Strömberg\scoop\modules;C:\Users\Peter Strömberg\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
PUBLIC=C:\Users\Public
SESSIONNAME=RDP-Tcp#0
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\PETERS~1\AppData\Local\Temp
TMP=C:\Users\PETERS~1\AppData\Local\Temp
USERDOMAIN=PC
USERDOMAIN_ROAMINGPROFILE=PC
USERNAME=Peter Strömberg
USERPROFILE=C:\Users\Peter Strömberg
windir=C:\Windows
The only trace I can see from the installer is that it puts to the problematic binary first in the Path variable…
That's some really great sleuthing, Peter! On windows it is only the path that determines which command you will find when you run 'java'. Since Oracle has put their directory first in the path, that one will win. An alternative may be using %JAVA_HOME%\bin\java.exe, but I am not sure if everyone that has java installed has that environment variable set.
Right now I think what’s most urgent is to inform about this on https://calva,io.
And docs are updated now: https://calva.io/getting-started/#theres-a-getting-started-repl
Bug reported to Oracle about it: https://github.com/BetterThanTomorrow/calva/issues/1162#issuecomment-830920272