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.
borkdude 2020-06-11T18:32:41.117800Z

According to stackoverflow something like this should store the output of clojure into the variable $x:

$x=(clojure -Spath -Sdeps '{:deps {org.clojure/data.zip {:mvn/version \"1.0.0\"}}}') | Out-String                          
(PowerShell). Why doesn't it work?

borkdude 2020-06-11T18:35:37.118300Z

Maybe it's an issue with clojure:

$x=(echo "hello") | Out-String 
echo $x
"hello"

borkdude 2020-06-11T18:36:44.118500Z

yes. deps.clj does it correctly. https://github.com/borkdude/deps.clj

alexmiller 2020-06-11T19:03:19.119900Z

I notice the powershell impl does Write-Host $CP, not sure if that should be Write-Out ?

borkdude 2020-06-11T19:04:13.120200Z

it probably should, although I'm not a PS expert

alexmiller 2020-06-11T19:04:24.120500Z

from some googling, I think so

alexmiller 2020-06-11T19:04:53.120800Z

this kind of thing works in the *nix clojure

borkdude 2020-06-11T19:05:32.121Z

I use it all the time

alexmiller 2020-06-11T19:08:40.121300Z

I fixed that and another case in -Sdescribe

alexmiller 2020-06-11T19:09:07.121900Z

Write-Host is now only used for purely out of band informational messages

borkdude 2020-06-11T19:09:24.122200Z

is Write-Host the stderr of PS?

alexmiller 2020-06-11T19:09:33.122400Z

no, there is Write-Error too

alexmiller 2020-06-11T19:09:44.122700Z

Write-Host truly only writes to the host and does write to out or err

alexmiller 2020-06-11T19:09:52.123Z

afaict

alexmiller 2020-06-11T19:10:19.123400Z

terminal is seeing all of them, but matters when pipelining

borkdude 2020-06-11T19:11:07.123600Z

thanks for fixing

alexmiller 2020-06-11T19:13:19.124200Z

I've got some pending minor fixes in tda, let me release that and then I'll push a new dev release of clj stuff

borkdude 2020-06-11T19:14:03.124400Z

:bananadance:

alexmiller 2020-06-11T19:55:27.124700Z

@borkdude fixed in 1.10.1.547

👍 1
borkdude 2020-06-11T20:59:34.125200Z

TIL that this "just works" on Windows:

user=&gt; (require '[<http://clojure.java.io|clojure.java.io> :as io])
nil
user=&gt; (io/file "src" "babashka/main.clj")
#object[java.io.File 0x722c07fa "src\\babashka\\main.clj"]

borkdude 2020-06-11T20:59:50.125600Z

so you don't have to use the platform specific file separator there

seancorfield 2020-06-11T21:04:26.126400Z

Yeah, but given that all the file APIs return \ in them, your code still needs to deal with both 😞

borkdude 2020-06-11T21:05:11.127Z

in my case I was scanning directories and .jar files for existing entries, so I can get away with only using one suffix string

borkdude 2020-06-11T21:09:37.128200Z

you would maybe say: but Java already has something for this, it's called URLClassLoader or something. yeah, I tried, but GraalVM doesn't support this class because they can't dynamically load classes. it still would have been useful for just finding stuff, but ok

borkdude 2020-06-11T21:13:09.129500Z

this worked ok for months, but now someone on Windows complained they couldn't load a library from a .jar file. turned out I was overcorrecting the path using a Windows-specific backwards slash when searching a jar file