clj-on-windows

For those interested in making clj on Windows https://dev.clojure.org/jira/browse/TDEPS-67. Also see https://github.com/littleli/scoop-clojure.
vlaaad 2021-05-25T20:14:52.005900Z

There is a difference between windows/linux in how :jvm-opts args in aliases are picked up:

PS C:\Users\Vlaaad\Projects\repro> Get-Content .\deps.edn
{:aliases {:opt {:jvm-opts ["-Drepro.opt=YES"]
                 :exec-fn checkopt/exec}}}
PS C:\Users\Vlaaad\Projects\repro> Get-Content .\src\checkopt.clj
(ns checkopt)

(defn exec [_]
  (prn (System/getProperty "repro.opt")))
PS C:\Users\Vlaaad\Projects\repro> clj -X:opt
nil
PS C:\Users\Vlaaad\Projects\repro> wsl
vlaaad@asus-notebook:/mnt/c/Users/Vlaaad/Projects/repro$ clj -X:opt
"YES"
vlaaad@asus-notebook:/mnt/c/Users/Vlaaad/Projects/repro$

vlaaad 2021-05-25T20:16:41.006600Z

Using version "1.10.3.849" both on windows and linux

borkdude 2021-05-25T20:16:53.006900Z

@vlaaad for completeness, could you also try with bb clojure -X:opt ?

borkdude 2021-05-25T20:17:20.007100Z

(with a newer version of bb)

vlaaad 2021-05-25T20:17:43.007400Z

I don't use bb, sorry @borkdude

borkdude 2021-05-25T20:18:12.007800Z

this could be interesting to find out if it's a powershell issue or something else

borkdude 2021-05-25T20:18:32.008200Z

since bb uses the exact same code, not platform specific

borkdude 2021-05-25T20:19:18.008600Z

an alternative is https://github.com/borkdude/deps.clj/releases/download/v0.0.15/deps.clj-0.0.15-windows-amd64.zip run as deps -X:opt

borkdude 2021-05-25T20:19:42.009200Z

(this is the same code as used in bb, but a standalone executable dedicated to only this)

borkdude 2021-05-25T20:20:58.009500Z

just a suggestion for debugging

alexmiller 2021-05-25T20:33:28.010100Z

can you also retry the repro with -Sforce in both cases to make sure there are no cache effects

alexmiller 2021-05-25T20:33:42.010400Z

or rm .cpcache/

vlaaad 2021-05-25T21:06:08.010700Z

@alexmiller same result:

PS C:\Users\Vlaaad\Projects\repro> clj -Sforce -X:opt
nil
PS C:\Users\Vlaaad\Projects\repro> wsl
vlaaad@asus-notebook:/mnt/c/Users/Vlaaad/Projects/repro$ clj -Sforce -X:opt
"YES"

borkdude 2021-05-25T21:09:03.011Z

@vlaaad what Java versions are you using in both envs?

borkdude 2021-05-25T21:11:21.011500Z

I know there is an issue with Oracle 15+ that is dropping quotes on Windows, which is why I am asking.

littleli 2021-05-25T21:13:05.012Z

@borkdude

temp $ bb clojure -X:opt
"YES"

temp $ clj -X:opt
nil

temp $ java -version
openjdk version "16" 2021-03-16
OpenJDK Runtime Environment AdoptOpenJDK (build 16+36)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 16+36, mixed mode, sharing)

borkdude 2021-05-25T21:14:52.012700Z

is this windows or wsl

littleli 2021-05-25T21:15:07.012900Z

Windows + Powershell

borkdude 2021-05-25T21:15:14.013100Z

ok

vlaaad 2021-05-25T21:15:29.013500Z

@borkdude 14.0.1 on windows and 11.0.11 on linux

borkdude 2021-05-25T21:16:10.013600Z

and what do you get for clj ?

borkdude 2021-05-25T21:17:55.014Z

which vendors? please more info :)

alexmiller 2021-05-25T21:25:10.015Z

on the linux one, if you add -Sverbose you'll see a line like "cp_file = .cpcache/4068492893.cp". for whatever that hash value is can you cat .cpcache/HASH.jvm

littleli 2021-05-25T21:26:13.015200Z

temp $ clj -X:opt
nil

borkdude 2021-05-25T21:26:40.015700Z

meanwhile @ales.najmann tried out both bb clojure and clj in powershell and the clj one failed: https://clojurians.slack.com/archives/CFN4QDHPS/p1621977973015200?thread_ts=1621977185.012000&cid=CFN4QDHPS

borkdude 2021-05-25T21:30:25.016600Z

@alexmiller Perhaps you forgot to apply the powershell workaround that you did for -M and -A, for -X ? https://github.com/clojure/brew-install/blob/bd10d7aba00074f0b725b6fc81be32e01d798795/src/main/resources/clojure/install/ClojureTools.psm1#L85

alexmiller 2021-05-25T21:30:50.017200Z

I can't actually repro this on mac

alexmiller 2021-05-25T21:31:08.017800Z

which is same bash as linux

borkdude 2021-05-25T21:31:32.018600Z

The mac powershell parses differently than the windows one. The windows one splits -X:foo into two args -X: and foo (or perhaps the colon on the other side)

alexmiller 2021-05-25T21:31:34.018700Z

the parsing is intentionally different in windows due to the : stuff

borkdude 2021-05-25T21:32:16.019500Z

that parsing is only different in windows + powershell.

borkdude 2021-05-25T21:32:21.019700Z

not in cmd.exe

alexmiller 2021-05-25T21:33:17.020300Z

not sure I'm following

borkdude 2021-05-25T21:33:46.021300Z

the mac powershell parses it "correctly" but the windows powershell (specifically: windows AND powershell, that specific combination) parse -F:foo into two parts

alexmiller 2021-05-25T21:33:47.021400Z

to be clear, you are off on a side quest here from the original question about linux -X not picking up :jvm-opts, right?

littleli 2021-05-25T21:34:47.022400Z

it works ok on Linux (or WSL), the same does not on Windows

alexmiller 2021-05-25T21:35:07.022900Z

well now I'm totally confused

borkdude 2021-05-25T21:35:09.023Z

it does work ok with tools.deps.alpha on Windows, just not with the powershell front-end

borkdude 2021-05-25T21:35:52.023500Z

(as @ales.najmann showed in this thread: https://clojurians.slack.com/archives/CFN4QDHPS/p1621977185012000)

borkdude 2021-05-25T21:36:01.023900Z

I'll back off now ;)

alexmiller 2021-05-25T21:36:12.024200Z

rereading, I had the problem completely backwards, sorry

alexmiller 2021-05-25T21:36:24.024600Z

I thought it was linux not working and windows working

littleli 2021-05-25T21:36:50.024800Z

damn Windows once again 🙂

alexmiller 2021-05-25T21:37:36.025400Z

so, I would actually like to know the answer to the .jvm file question I asked above

borkdude 2021-05-25T21:38:05.026200Z

(and the vendor of both the JVMs, which could also be a difference, as shown in the adventures of @pez)

alexmiller 2021-05-25T21:38:21.026600Z

if you clj -Sverbose -X:opt then grab the hash and look at .cpcache/HASH.jvm

alexmiller 2021-05-25T21:39:39.027500Z

what I am trying to see is whether the make-classpath program is properly understanding the alias and writing the cache file OR whether the problem is in reading the file and applying the jvm properties in the pwsh

littleli 2021-05-25T21:40:37.028Z

@alexmiller

temp $ clj -Sverbose -X:opt
version      = 1.10.3.849
install_dir  = C:\Users\alesn\scoop\modules\ClojureTools
config_dir   = C:\Users\alesn\.clojure
config_paths = C:\Users\alesn\scoop\modules\ClojureTools\deps.edn C:\Users\alesn\.clojure\deps.edn deps.edn
cache_dir    = .cpcache
cp_file      = .cpcache\9A0695B47F76E40743FC037AEAF297A7.cp
nil

temp $ Get-Content .\.cpcache\9A0695B47F76E40743FC037AEAF297A7.jvm   
-Drepro.opt=YES

alexmiller 2021-05-25T21:41:19.028500Z

actually I'm pretty sure it's the latter - this is just missing on the exec branch

alexmiller 2021-05-25T21:45:35.029200Z

give me a minute, and I'll have a build for you

alexmiller 2021-05-25T21:46:14.029500Z

ok, grab the windows build version 1.10.3.855 and give it a try

1🚀
littleli 2021-05-25T21:53:02.030300Z

Ok. I'm wrestling now with scoop... but it's already downloading the right thing

littleli 2021-05-25T21:55:09.030600Z

temp $ clj -Sverbose -X:opt
version      = 1.10.3.855
install_dir  = C:\Users\alesn\scoop\modules\ClojureTools
config_dir   = C:\Users\alesn\.clojure
config_paths = C:\Users\alesn\scoop\modules\ClojureTools\deps.edn C:\Users\alesn\.clojure\deps.edn deps.edn
cache_dir    = .cpcache
cp_file      = .cpcache\9A0695B47F76E40743FC037AEAF297A7.cp
"YES"
temp $ bb clojure -X:opt
"YES"

2🎉
alexmiller 2021-05-25T21:55:51.031Z

YES YES YES

littleli 2021-05-25T21:55:55.031300Z

😄

alexmiller 2021-05-25T21:55:57.031400Z

such positive affirmations in this test

borkdude 2021-05-25T21:59:01.032200Z

I'm glad another clj on windows issue got solved today. YES!

littleli 2021-05-25T22:02:22.034500Z

autoupdate script parses release page, so after the update of this page https://clojure.org/releases/tools fix can make it to users

littleli 2021-05-25T22:06:32.035200Z

I wonder if I can use brew-install release page to check for releases

borkdude 2021-05-25T22:10:05.035700Z

@ales.najmann maybe checking the tags here works better? https://github.com/clojure/brew-install/releases github has an API for this

littleli 2021-05-25T22:12:02.036Z

yes, I believe scoop github actions actually use this internally.

borkdude 2021-05-25T22:12:14.036200Z

https://api.github.com/repos/clojure/brew-install/tags

alexmiller 2021-05-25T22:13:43.036400Z

the tags there are ALL releases, both prerelease and stable

borkdude 2021-05-25T22:14:45.036600Z

you can flag prereleases as such in github

alexmiller 2021-05-25T22:15:13.036800Z

I'm using git programatically, not github

littleli 2021-05-25T22:15:43.037Z

I see

littleli 2021-05-25T22:15:57.037200Z

I'll probably stick to release page then

littleli 2021-05-25T22:16:14.037400Z

@borkdude the PR would look like this: https://github.com/littleli/scoop-clojure/pull/161/files

alexmiller 2021-05-25T22:16:20.037600Z

and really the homebrew repo makes no distinction - there is a tag for every @version release of the formula

alexmiller 2021-05-25T22:16:45.037800Z

"stable" is a subset of those where we bump the default clojure.rb formula

borkdude 2021-05-25T22:17:04.038Z

you can also use github programmatically, I've scripted (almost) all my binary uploads to github releases now: releases are created automatically, or only added to if they already exists, etc

littleli 2021-05-25T22:17:10.038200Z

so should I realy point to repo with clojure.rb formula?

alexmiller 2021-05-25T22:17:14.038400Z

oh sorry, you're looking at brew-install, same difference I guess

alexmiller 2021-05-25T22:18:30.038600Z

I don't want to flag releases differently on brew-install though - I don't know at the time of tagging whether it will be a stable release or not

alexmiller 2021-05-25T22:18:55.038800Z

promotion to stable is a separate process as far as I'm concerned

littleli 2021-05-25T22:20:22.039Z

no worries. I'll stick to release page (as a changelog) it was working fine for months.

littleli 2021-05-25T22:20:30.039200Z

and it's safe

alexmiller 2021-05-25T22:20:33.039400Z

I think the best things to look at are either the stable.properties file in brew-install (somewhat annoying due to the changing branch name, which I may end up changing as its a pain elsewhere) or to watch the clojure.rb formula in the homebrew-tools repo

alexmiller 2021-05-25T22:20:47.039600Z

also, I've updated the release page

littleli 2021-05-25T22:22:17.039800Z

it will be autoupdated in ~45-60 minutes

littleli 2021-05-25T22:22:31.040Z

Thank you for the debugging session 🙂 it was nice

littleli 2021-05-25T22:27:41.040200Z

@borkdude

scoop-clojure master = $ checkver

cmdlet checkver.ps1 at command pipeline position 1
Supply values for the following parameters:
Dir: bucket
clojure: 1.10.3.855 (scoop version is 1.10.3.849) autoupdate available
clojure-lsp: 2021.05.22-16.50.45
deps.clj: 0.0.15
datalevin: 0.4.34
jet: 0.0.15
bb-web: 0.2.4
puget: 0.0.3
carve: 0.0.2
lmgrep: 2021.05.23
pgmig: 0.7.0
bootleg: 0.1.9
babashka: 0.4.3
pathom-viz: 2021.5.13
clj-kondo: 2021.04.23
joker: 0.17.1

1🎉
littleli 2021-05-25T22:29:16.040500Z

but I need to let Excavator (github-action) to process it on scheduled time (~0 minute every hour)