Fork me on GitHub
#calva
<
2021-05-02
>
pez06:05:34

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.

pez06:05:07

Error: Could not find or load main class clojure.main
Caused by: java.lang.ClassNotFoundException: clojure.main

pez07:05:25

I added some more detail, and a repro, as a comment on the issue. https://github.com/BetterThanTomorrow/calva/issues/1162#issuecomment-830765259

pez08:05:28

And now I find out that I can run this using this Java 16: scoop install adopt16-hotspot

pez09:05:26

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.

pez12:05:44

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.

Stuart12:05:01

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

pez13:05:46

Try with the CMD prompt, @qmstuart, (that command line is not for PowerShell).

pez13:05:41

(But maybe the clojure command can’t even be run from the CMD prompt?)

Stuart13:05:19

yeah, doesnt recognise it as a command

Stuart13:05:23

maybe that's a path pronlem

Stuart13:05:27

yeah, dont think it will work with cmd, I think clojure CLI installs itself a ps module

pavlosmelissinos13:05:18

@qmstuart Your -Sdeps string is not valid. You should escape the inner strings with \" (instead of "")

pez13:05:33

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]'

pavlosmelissinos13:05:39

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]'

pavlosmelissinos13:05:41

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]"

pez13:05:41

@pavlos it seems to be a Java issue, actually. Which version of Java are you using?

👍 1
Stuart13:05:50

sorry for screenshots, but PS seems to be a pain to copy and paste from

pez14:05:23

@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).

borkdude15:05:46

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 """..."""}}}"

🤷 1
borkdude15:05:15

and I did not use the official clojure CLI but deps.clj

borkdude15:05:33
replied to a thread:

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"

borkdude15:05:36
replied to a thread:

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"

borkdude16:05:34

I cannot reproduce any of the issues with any JDK, Oracle or not. Feel free to reach out if you have some new information.

pez19:05:01

Latest findings regarding Getting Started REPL problems on Windows: https://github.com/BetterThanTomorrow/calva/issues/1162#issuecomment-830857709

seancorfield19:05:24

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)

pez19:05:49

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.

pez19:05:59

The challenge remains to find the working executable.

pez19:05:32

My google fu fails me. I don’t know how to do the equivalent of env on Windows.

seancorfield20:05:34

In cmd.exe, the set command...

seancorfield20:05:17

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

pez22:05:53

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

pez22:05:26

The only trace I can see from the installer is that it puts to the problematic binary first in the Path variable…

stianalmaas07:05:12

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.

pez08:05:06

Right now I think what’s most urgent is to inform about this on https://calva,io.

pez23:05:41

Totally failing in finding workarounds. No amount of double quotes or quoting of double quotes gets through. I might end up just trying to detect the situation and then inform the user about installing java from somewhere else. Sucks, but I am completely out of better ideas now.