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.
carkh 2019-08-02T01:16:24.319800Z

@sogaiu probably need a nimble install zip for the "cannot open file zip/zipfiles"

carkh 2019-08-02T01:18:04.320200Z

the install does indeed have tdeps-120 fix

carkh 2019-08-02T01:25:08.321100Z

the docker compilation is zero config required, so that would be the prefered way for testing compilation

2019-08-02T01:52:46.322100Z

thanks for the tips -- regarding docker: do you need to install something to use docker? i haven't really used docker.

carkh 2019-08-02T02:15:29.323700Z

@sogaiu that's just an apt-get away if i recall correctly, I never developed on linux and managed it, so i'd say it's pretty easy =)

carkh 2019-08-02T02:16:36.324200Z

it makes the build reproducible without any configuration effort

carkh 2019-08-02T02:18:00.324900Z

they have very newbie friendly installation/gettign started pages

carkh 2019-08-02T03:14:49.325600Z

I think that's out of our hands, i tried it (though graalvm isn't yet installed here), and of course get an error, but that's ajava error, so that means we're already started... unless clj.native_image calls clojure.exe again, the problem will be internal to graalvm ?

2019-08-02T05:14:51.326900Z

unfortunately, sh script/docker_build gave the following:

mkdir: cannot create directory β€˜dockerout/’: File exists
**** Building the docker image 
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post <http://%2Fvar%2Frun%2Fdocker.sock/v1.40/build?buildargs=%7B%7D&amp;cachefrom=%5B%5D&amp;cgroupparent=&amp;cpuperiod=0&amp;cpuquota=0&amp;cpusetcpus=&amp;cpusetmems=&amp;cpushares=0&amp;dockerfile=Dockerfile&amp;labels=%7B%7D&amp;memory=0&amp;memswap=0&amp;networkmode=default&amp;rm=1&amp;session=ek963fgyyx0zigxuid1xvqp45&amp;shmsize=0&amp;t=clojureclibuild&amp;target=&amp;ulimits=null&amp;version=1>: dial unix /var/run/docker.sock: connect: permission denied
!!!!!!!!!!!!! ERROR : Error building docker image !!!!!!!!!!!!!

2019-08-02T05:15:04.327300Z

does this mean i need root privs to build?

2019-08-02T05:15:28.327700Z

i'm not sure i'm comfortable with that sort of requirement just for building

carkh 2019-08-02T05:18:04.329700Z

no need for root

2019-08-02T05:18:05.329800Z

after removing the dockerout directory and rerunning, i got a similar error:

**** Building the docker image 
ERRO[0000] failed to dial gRPC: cannot connect to the Docker daemon. Is 'docker daemon' running on this host?: dial unix /var/run/docker.sock: connect: permission denied 
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post <http://%2Fvar%2Frun%2Fdocker.sock/v1.40/build?buildargs=%7B%7D&amp;cachefrom=%5B%5D&amp;cgroupparent=&amp;cpuperiod=0&amp;cpuquota=0&amp;cpusetcpus=&amp;cpusetmems=&amp;cpushares=0&amp;dockerfile=Dockerfile&amp;labels=%7B%7D&amp;memory=0&amp;memswap=0&amp;networkmode=default&amp;rm=1&amp;session=ba26ydwtuk58x7iwdmodlp0k8&amp;shmsize=0&amp;t=clojureclibuild&amp;target=&amp;ulimits=null&amp;version=1>: dial unix /var/run/docker.sock: connect: permission denied
!!!!!!!!!!!!! ERROR : Error building docker image !!!!!!!!!!!!!
i'm just reporting for feedback purposes -- i'm not that into getting docker to work, so don't worry πŸ™‚

carkh 2019-08-02T05:18:27.330100Z

did you try the hello-world docker image ?

2019-08-02T05:18:38.330300Z

no i didn't

carkh 2019-08-02T05:18:49.330700Z

that's a docker issue

carkh 2019-08-02T05:19:04.331200Z

oh you need to be in the docker group

carkh 2019-08-02T05:19:15.331500Z

as a user

2019-08-02T05:19:22.331700Z

ok, i will try that

carkh 2019-08-02T05:22:20.332200Z

docker run hello-world is the first thing you should try after installing it

2019-08-02T05:22:48.332700Z

well, i'm not keen on docker πŸ™‚ but at any rate, your advice seemed to allow things to proceed further, so thanks for that!

carkh 2019-08-02T05:24:01.333500Z

my goal there was to make it so no installation woudl be required outside of docker, which is well documented

2019-08-02T05:24:41.334200Z

no worries -- you're just dealing with an opinionated ex-system administrator who has preferences in other directions πŸ™‚

carkh 2019-08-02T05:25:17.334800Z

i'm seeing it from my linux newbie point of view, make it easy =)

2019-08-02T05:25:44.335200Z

why am i reminded of a rich hickey talk? πŸ™‚

carkh 2019-08-02T05:26:07.335600Z

well, that's not idle easiness though

carkh 2019-08-02T05:26:30.336Z

build reproductability is at stakes

2019-08-02T05:26:49.336500Z

i agree about importance of build reproducibility -- that's a good thing

2019-08-02T05:26:53.336700Z

it's just a matter of means

carkh 2019-08-02T05:27:48.337900Z

maybe my ignorance of the linux world, but i don't see how to script the installation of required dependencies across all distributions, and mac too

2019-08-02T05:29:40.340Z

i don't know of any magical method to handle this stuff well. as i understand it, some folks use continuous integration systems such as circleci and such for this sort of thing.

carkh 2019-08-02T05:30:05.340400Z

yes that's another solution, but that's still docker under the hood!

2019-08-02T05:30:27.341Z

i didn't get the feeling that all such systems used docker under the hood -- is that really the case?

carkh 2019-08-02T05:30:34.341500Z

also i don't know that the user/builder has that working

carkh 2019-08-02T05:31:19.342200Z

sogaiu: well i assumed that, there must be some kind of virtualization going on

2019-08-02T05:31:27.342300Z

i'm pretty sure nixos doesn't for example

2019-08-02T05:31:49.342600Z

isn't docker kind of a pseudo virtualization thing?

2019-08-02T05:32:02.343100Z

ah, the build seems to have complete successfully πŸ™‚

carkh 2019-08-02T05:32:07.343300Z

weee !

2019-08-02T05:32:12.343500Z

nice!

carkh 2019-08-02T05:32:53.343900Z

so i downloaded graalvm to test with adorn

carkh 2019-08-02T05:33:11.344300Z

but chrome is trying to verify the download

carkh 2019-08-02T05:33:22.344700Z

it has been doing so for hours now

2019-08-02T05:33:24.344800Z

ha ha ha

2019-08-02T05:33:30.345Z

sorry it's giving you trouble

2019-08-02T05:33:35.345200Z

may be it's not worth your time

carkh 2019-08-02T05:34:09.345500Z

well that's chrome's time, i don't care =)

2019-08-02T05:38:38.346300Z

lol -- btw, i copied the docker-built installer to the windows 10 pro machine and ran it with some success, and the installed clj seems to be working on the few things i tried it on πŸ™‚

carkh 2019-08-02T05:38:57.346600Z

very nice !

2019-08-02T05:39:05.347Z

good job!

carkh 2019-08-02T05:39:19.347300Z

there is a new -Scp-jar switch to force using a classpath jar, for testing

2019-08-02T05:39:33.347600Z

will take a look

2019-08-02T05:41:38.348200Z

not sure if i'm using it right, but i get: Error: Could not find or load main class clojure.main for the input: clj -Scp-jar in a clojure project directory

carkh 2019-08-02T05:41:51.348400Z

oh god ><

carkh 2019-08-02T05:41:56.348600Z

i'll chekc it out

carkh 2019-08-02T05:41:59.348800Z

that is a bug

carkh 2019-08-02T05:43:27.349100Z

works here though

carkh 2019-08-02T05:43:43.349500Z

i'll rebuild and try again

2019-08-02T05:45:05.349900Z

i can test with a different installer

2019-08-02T05:46:43.350300Z

i tried with the installer.exe from the releases page for 0.0.6 and got the same results

carkh 2019-08-02T05:47:58.350600Z

that-s very strange it works here

carkh 2019-08-02T05:48:10.350900Z

you're on windows, right ?

carkh 2019-08-02T05:48:20.351100Z

yes obviously

carkh 2019-08-02T05:48:50.351400Z

try adding a -Srepro switch

carkh 2019-08-02T05:49:06.351700Z

and maybe giving me your deps.edn

carkh 2019-08-02T05:50:21.352400Z

java is very fiddly with classpaths in a jar, might be that it cannot find a file or a directory and just bails out

2019-08-02T05:51:30.353Z

i tried with 2 projects -- also tried with the -Srepro switch, but no change in output -- one of the projects is adorn, so you have the deps.edn for that i think

2019-08-02T05:51:40.353300Z

should i look for another project to try with?

carkh 2019-08-02T05:52:11.353500Z

let me try adorne again

carkh 2019-08-02T05:52:47.353700Z

ah go it there

carkh 2019-08-02T05:52:51.353900Z

same output

2019-08-02T05:53:44.354200Z

ah, with depstar it doesn't give that output

2019-08-02T05:54:32.354900Z

didn't need -Srepro for depstar for it to work -- clj -Scp-jar worked as-is

carkh 2019-08-02T05:54:37.355Z

looks like trouble with git deps

carkh 2019-08-02T05:55:49.355900Z

i'll have to think on that one, i may be missing abit of data to be able to do it without support from tools.deps

carkh 2019-08-02T05:55:56.356100Z

going for coffee

2019-08-02T05:56:04.356300Z

πŸ™‚

carkh 2019-08-02T06:32:26.356700Z

https://github.com/cark/clojure-cli-portable Now with git deps in classpath jar bug fixed

2019-08-02T06:38:09.358Z

@carkh it's looking a bit better -- of the 2 projects i had problems with before, 1 of them now works. perhaps you saw already, but adorn gives the following error when invoked with clj -Scp-jar -A:native-image:

clj -Scp-jar -A:native-image
Exception in thread "main" java.nio.file.InvalidPathException: Illegal char &lt;:&gt; at index 2: \C:\Users\user\.m2\repository\com\cognitect\transit-java\0.8.332\transit-java-0.8.332.jar
        at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
        at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
        at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
        at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
        at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
        at java.nio.file.Paths.get(Paths.java:84)
        at com.oracle.svm.core.util.ClasspathUtils.stringToClasspath(ClasspathUtils.java:49)
        at com.oracle.svm.driver.NativeImage.handleClassPathAttribute(NativeImage.java:917)
        at com.oracle.svm.driver.NativeImage.processManifestMainAttributes(NativeImage.java:886)
        at com.oracle.svm.driver.NativeImage.addImageClasspathEntry(NativeImage.java:1330)
        at com.oracle.svm.driver.NativeImage.addCustomImageClasspath(NativeImage.java:1300)
        at com.oracle.svm.driver.DefaultOptionHandler.consume(DefaultOptionHandler.java:102)
        at com.oracle.svm.driver.NativeImage$NativeImageArgsProcessor.apply(NativeImage.java:1249)
        at com.oracle.svm.driver.NativeImage.processNativeImageArgs(NativeImage.java:1449)
        at com.oracle.svm.driver.NativeImage.completeImageBuild(NativeImage.java:929)
        at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1175)
        at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1145)
        at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1104)

carkh 2019-08-02T06:39:36.358200Z

i don't get that

carkh 2019-08-02T06:40:21.358300Z

the regular error

carkh 2019-08-02T06:41:23.358900Z

that's an error from nativeimage you have there

carkh 2019-08-02T06:41:36.359400Z

so the process indeed started correctly

2019-08-02T06:41:48.359700Z

that error you mentioned i get when i don't have GRAALVM_HOME set appropriately

carkh 2019-08-02T06:42:10.360200Z

I have no graalvm at all ...chrome still checking it =)

2019-08-02T06:42:26.360400Z

well, then i guess it's not surprising πŸ™‚

carkh 2019-08-02T06:43:30.361100Z

but you did get in, my guess is that nativeimage is rebuilding a classpath

carkh 2019-08-02T06:43:45.361400Z

and wants unix classpaths

carkh 2019-08-02T06:44:04.361900Z

but i don't know how to specify that...We're on windows so there is a colon

carkh 2019-08-02T06:44:16.362100Z

the trouble is with them i think

2019-08-02T06:46:38.362500Z

strangely enough, there is some discussion of something similar: https://stackoverflow.com/questions/43972777/exception-in-thread-main-java-nio-file-invalidpathexception-illegal-char

2019-08-02T06:47:47.363200Z

not sure if it's relevant but the comments at: https://stackoverflow.com/a/43972833 has something

carkh 2019-08-02T06:48:15.363600Z

can't remove the leading /

carkh 2019-08-02T06:48:26.363900Z

or it will just not work with a classpath jar

2019-08-02T06:49:18.364200Z

ah well

2019-08-02T08:14:14.365800Z

about -Scp-jar -- borkdude's clj-kondo builds an uberjar to hand to native-image -- iiuc, that piece more or less works under windows. is that a similar approach? fwiw, the relevant script is here: https://github.com/borkdude/clj-kondo/blob/master/script/compile.bat

2019-08-02T08:26:30.366600Z

would examining an uberjar built in this manner provide any hints / help?

carkh 2019-08-02T08:46:34.367Z

hum but do you have more success without -Scp-jar ?

2019-08-02T09:01:56.367600Z

native-image has a -jar option that allows one to pass in a jar -- if i build an uberjar and hand it to native-image that way, the build completes

carkh 2019-08-02T09:11:21.368700Z

how do you build your uberjar ?

carkh 2019-08-02T09:12:31.369600Z

the whole windows sdk7.1 + remove redistributables is annoying to say the least ... i'm not sure this project is a good test bed for the cli tools

2019-08-02T09:54:31.373400Z

@carkh uberjar can be built by using leiningen: e.g. https://github.com/borkdude/clj-kondo/blob/master/script/compile.bat#L16 -- so that means a project.clj becomes necessary. it's unfortunate, but apparently until the clj / clojure thing becomes usable, it is at least a work-around that works. regarding the windows sdk 7.1 thing -- yes highly unfortunate. it might be that the windows sdk thing will work if installed from chocolatey, but i didn't find that to work (installation was successful, but building with it was not). yes, perhaps it's not worth your time. please forget the adorn thing for cli tools testing. perhaps i should find some other good projects to test with -- at least depstar seems to be helping in this regard πŸ™‚

carkh 2019-08-02T09:55:52.374200Z

maybe the uberjar may be built with a deps.edn project

carkh 2019-08-02T09:57:25.374800Z

you're starting the clj.native-image scritp directly from the main-opts

carkh 2019-08-02T09:57:40.375200Z

so i guess it's doing the work to actually build the image right there

2019-08-02T10:06:09.378300Z

for building uberjars, i'm not sure whether aot is necessary for this type of situation, but if it is, the number of options available via deps.edn shrinks a bit (e.g. depstar doesn't do aot) -- there are other interesting seeming options (e.g. badigeon and pack), but i haven't really learned how to use them just yet. actually, i think i'm starting to remember that aot is necessary. adorn's deps.edn uses taylorwood's clj.native-image project (https://github.com/taylorwood/clj.native-image) for building the native image binary -- that's what is invoked via the alias. so iiuc it's actually clj.native-image that calls graalvm's native-image binary. fwiw, in the deps.edn alias, "script" is just the name of a namespace.

carkh 2019-08-02T10:16:36.379500Z

looking at https://clojure.org/reference/compilation#_gen_class_examples, it sure was easier with lein =)

carkh 2019-08-02T10:17:17.379700Z

we're back at doing it manually

2019-08-02T11:06:36.380400Z

it was certainly easy to do aot with lein. perhaps this isn't so bad? https://github.com/juxt/pack.alpha#uberjar

2019-08-02T11:13:44.381100Z

on second thought, it's not clear about whether there is aot support there...

timgilbert 2019-08-02T13:55:08.382400Z

When I was messing with the TDEPS-120 stuff earlier, I found the format of the MANIFEST.MF file to be exceedingly finicky (one reason I wound up falling back on the built-in JDK methods to generate it)

timgilbert 2019-08-02T13:58:45.382900Z

Eg, the second block of code is how they approached it in Gradle here: https://discuss.gradle.org/t/filename-too-long-in-windows/9222/15

2019-08-02T14:01:43.383600Z

the following is what you mean by built-in JDK methods? https://github.com/timgilbert/lein-classpath-jar/blob/master/src/lein_classpath_jar/plugin.clj#L51-L54

timgilbert 2019-08-02T14:07:06.384800Z

Yeah, right. Doing it externally you need to add in like a header and then wrap every line at exactly 70 characters or something

timgilbert 2019-08-02T14:07:15.385100Z

It is a truly annoying file format

carkh 2019-08-02T14:13:26.386400Z

@timgilbert yes also it will silently fail if a directory isn't there

carkh 2019-08-02T14:13:43.386800Z

so i have to check if these exist

carkh 2019-08-02T14:14:19.387400Z

and each line is limited to a very small value, like 128characters IIRC

carkh 2019-08-02T14:16:56.387700Z

it's 72bytes actually ><

timgilbert 2019-08-02T14:27:23.387900Z

Yeah

carkh 2019-08-02T15:13:04.388600Z

having fun with unicode as bytes, no breaking runes with a \n ...weee

carkh 2019-08-02T15:40:59.389900Z

i'm pretty sure the jvm doesn't enforce this limit, because it was working without truncating the lines, and many file names are longer than 72bytes on my config

carkh 2019-08-02T15:41:27.390300Z

anyways we're complying now : https://github.com/cark/clojure-cli-portable

timgilbert 2019-08-02T18:01:40.391Z

Hmm, getting an install error trying to compile this on windows:

CC: libzip_all
Error: invocation of external compiler program failed. The system cannot find the file specified.
Additional info: "Requested command not found: \'gcc.exe -c  -w -mno-ms-bitfields -DWIN32_LEAN_AND_MEAN -Os  -IC:\\Users\\tim\\scoop\\apps\\nim\\current\\lib -IC:\\Users\\tim\\src\\clojure-cli-portable\\src -o C:\\Users\\tim\\nimcache\\clojure_r\\libzip_all.c.o C:\\Users\\tim\\.nimble\\pkgs\\zip-0.2.1\\zip\\private\\libzip_all.c\'. OS error:" 2
!!! COMPILE ERROR !!!

timgilbert 2019-08-02T18:02:08.391700Z

I think it's just a problem with my local setup, I installed nim via scoop install nim

timgilbert 2019-08-02T18:02:28.392200Z

But I guess I don't have a gcc.exe on my path anywhere. Anyways, I will mess with it

carkh 2019-08-02T18:11:16.392400Z

i can help

carkh 2019-08-02T18:12:16.393200Z

what's your nim --version ?

timgilbert 2019-08-02T18:12:44.393800Z

Actually, seems like I hit a weird sourceforge bug installing gcc from scoop, but I got past that bit

carkh 2019-08-02T18:12:52.394200Z

oh

timgilbert 2019-08-02T18:12:58.394400Z

Needed to scoop install upx also

carkh 2019-08-02T18:13:17.394800Z

ahyes i should update the readme with that bit

carkh 2019-08-02T18:13:36.395Z

though it's not required

carkh 2019-08-02T18:14:04.395300Z

it's more of a finishing touch =)

timgilbert 2019-08-02T18:17:10.396600Z

Ok, got it compiled. Will take me a bit of time to test it as I need to try to eradicate the various other incarnations from my %PATH%

carkh 2019-08-02T18:17:26.396800Z

=)