This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-16
Channels
- # announcements (33)
- # atom-editor (1)
- # aws (21)
- # babashka (174)
- # babashka-sci-dev (2)
- # beginners (59)
- # calva (4)
- # chlorine-clover (9)
- # clj-kondo (51)
- # clojars (7)
- # clojure (86)
- # clojure-czech (4)
- # clojure-europe (21)
- # clojure-france (6)
- # clojure-nl (1)
- # clojure-uk (2)
- # conjure (7)
- # core-async (3)
- # core-logic (3)
- # cursive (10)
- # data-science (8)
- # datalevin (14)
- # datomic (12)
- # events (1)
- # fulcro (5)
- # graalvm (10)
- # gratitude (3)
- # honeysql (3)
- # hyperfiddle (3)
- # introduce-yourself (4)
- # joyride (3)
- # leiningen (3)
- # malli (13)
- # minecraft (15)
- # music (1)
- # off-topic (40)
- # pathom (16)
- # polylith (28)
- # portal (25)
- # rdf (15)
- # remote-jobs (3)
- # shadow-cljs (23)
- # specter (1)
- # sql (5)
- # tools-deps (25)
- # xtdb (31)
I've got an interesting issue on NixOS. I've cloned borkdude's https://github.com/borkdude/blog in order to start using that tooling for my own blog, and when I run bb render
, I get a ZipException
when trying to download the clj-kondo pod:
[jmglov@laurana:~/Documents/code/jmglov.net/blog]$ bb render
Downloading pod clj-kondo/clj-kondo (2021.10.19)
----- Error --------------------------------------------------------------------
Type: java.util.zip.ZipException
Message: invalid entry CRC (expected 0x7463ff01 but got 0x6bbe279e)
I'm running Babashka v0.8.156 on OpenJDK 17:
[jmglov@laurana:~/Documents/code/jmglov.net/blog]$ java -version
openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment (build 17.0.3+7-nixos)
OpenJDK 64-Bit Server VM (build 17.0.3+7-nixos, mixed mode, sharing)
Any ideas here?This probably is because you have a different zlib than graalvm expects. Have you compiled babashka yourself?
Yes. Looks like the https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/interpreters/clojure/babashka.nix derivation is building it with the following flags:
"-H:+ReportExceptionStackTraces"
"--no-fallback"
"--native-image-info"
I've seen this error before when the environment uses zlib other than ZLIB_VERSION="1.2.11"
I think it's better if the derivation compiled a static binary with 1.2.11 in the environment
You can download the static binary yourself and that should work (although that would be against the nix spirit I guess)
I can whip up an overlay that does this. It's odd that the person who updated Babashka from 0.8.2 to 0.8.156 didn't run into this issue, but as that commit is only 7 days old, maybe it just hasn't been used enough in the wild to uncover this issue.
yes, check out the linux-static job on circleci in the bb repo. but note that this only works for linux amd64
Yeah, 1.2.13 would be best. I could also apply the Arch patch when building zlib, I suppose.
I can probably backport the same patch Arch is using if this does fix the issue though, at least until 1.2.13 is released
In fact, that might be the easiest thing to do, though it would probably rebuild everything on my system. 😅
I need to repro this issue first though. Do the babashka test suite includes a test for this case?
So I need to overlay a zlib derivation that applies the Arch patch, then overlay a graal derivation that uses that zlib.
no, I think only having the patched zlib in your environment will be enough, since it's dynamically linked
@UFDRD93RR Are you running NixOS? I can give you a snippet that will definitely blow up.
Why does nix want to create 32 users on my mac?
build users:
Username: UID
_nixbld1: 301
_nixbld2: 302
_nixbld3: 303
_nixbld4: 304
_nixbld5: 305
_nixbld6: 306
_nixbld7: 307
_nixbld8: 308
_nixbld9: 309
_nixbld10: 310
The approach for this is to create separate users, so each package is build in isolation from one another
I think you can increase or decrease the number of users, but 32 looks like a good default anyway
Hence running nix build
with more than -j 32
is something no reasonable person would ever do. 😉
I'm deep in a rabbit hole that started when I just wanted to write a short blog entry. 😅
Sure, you can do. I'm talking about the flag that tells nix build
how many parallel builds to attempt.
ok, installed now: https://nix.dev/tutorials/install-nix
ok, on macos I also see zlib 1.2.12:
$ otool -L $(which bb)
/nix/store/msgq0r8v9kma3fqxmsr0mdylrxgv1y8x-babashka-0.8.156/bin/bb:
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1122.11.0)
/nix/store/kzba6lbw9sgzmvip6jjf35nz3nnmri8y-libcxx-11.1.0/lib/libc++.1.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/nix/store/7zfc5xjjigzh5i33rv7ph1hnma5x4rzz-zlib-1.2.12/lib/libz.dylib (compatibility version 1.0.0, current version 1.2.12)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1770.255.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1770.255.0)
This should explode:
$(nix-build ~/Downloads/bb.nix)/bin/bb <something that unzips stuff>
[nix-shell:~]$ rm -rf ~/.babashka/pods/repository
[nix-shell:~]$ bb -e "(babashka.pods/load-pod 'clj-kondo/clj-kondo \"2022.02.09\")"
Downloading pod clj-kondo/clj-kondo (2022.02.09)
Successfully installed pod clj-kondo/clj-kondo (2022.02.09)
#:pod{:id "pod.borkdude.clj-kondo"}
@U04V15CAJ Which bb version is that?
the JDK version doesn't matter, bb does not rely on a JDK except for shelling out to download some deps
I'm brand new to GraalVM, so most of my assumptions about how Java stuff works are gonna be really wrong. 😂
[nix-shell:~]$ rm -rf ~/.babashka/pods/repository
[nix-shell:~]$ bb -e "(babashka.pods/load-pod 'clj-kondo/clj-kondo \"2022.02.09\")"
Downloading pod clj-kondo/clj-kondo (2022.02.09)
Successfully installed pod clj-kondo/clj-kondo (2022.02.09)
#:pod{:id "pod.borkdude.clj-kondo"}
bb -e "(babashka.pods/load-pod 'clj-kondo/clj-kondo \"2022.02.09\")"
----- Error --------------------------------------------------------------------
Type: java.io.IOException
Message: Cannot run program "/home/thiagoko/.babashka/pods/repository/borkdude/clj-kondo/2022.02.09/clj-kondo": error=2, No such file or directory
Location: <expr>:1:1
----- Context ------------------------------------------------------------------
1: (babashka.pods/load-pod 'clj-kondo/clj-kondo "2022.02.09")
^--- Cannot run program "/home/thiagoko/.babashka/pods/repository/borkdude/clj-kondo/2022.02.09/clj-kondo": error=2, No such file or directory
----- Stack trace --------------------------------------------------------------
babashka.pods.impl/run-pod - <built-in>
babashka.pods.impl/load-pod - <built-in>
babashka.pods.sci/load-pod/fn--30887 - <built-in>
babashka.pods.sci/load-pod - <built-in>
clojure.core/apply - <built-in>
babashka.impl.pods/load-pod - <built-in>
user
@UFDRD93RR Try the rm -rf
first though
bb -e "(babashka.pods/load-pod 'clj-kondo/clj-kondo \"2022.02.09\")"
Downloading pod clj-kondo/clj-kondo (2022.02.09)
Successfully installed pod clj-kondo/clj-kondo (2022.02.09)
----- Error --------------------------------------------------------------------
Type: java.io.IOException
Message: Cannot run program "/home/thiagoko/.babashka/pods/repository/borkdude/clj-kondo/2022.02.09/clj-kondo": error=2, No such file or directory
Location: <expr>:1:1
----- Context ------------------------------------------------------------------
1: (babashka.pods/load-pod 'clj-kondo/clj-kondo "2022.02.09")
^--- Cannot run program "/home/thiagoko/.babashka/pods/repository/borkdude/clj-kondo/2022.02.09/clj-kondo": error=2, No such file or directory
----- Stack trace --------------------------------------------------------------
babashka.pods.impl/run-pod - <built-in>
babashka.pods.impl/load-pod - <built-in>
babashka.pods.sci/load-pod/fn--30887 - <built-in>
babashka.pods.sci/load-pod - <built-in>
clojure.core/apply - <built-in>
babashka.impl.pods/load-pod - <built-in>
user - <expr>:1:1
@UFDRD93RR Try 2022.05.31
- should work now
> So I don't think this is related to the zlib 1.2.12 issue at all I do think it's related: I've seen this happen before several times
bb -e "(babashka.pods/load-pod 'clj-kondo/clj-kondo \"2022.05.31\")"
Downloading pod clj-kondo/clj-kondo (2022.05.31)
----- Error --------------------------------------------------------------------
Type: java.util.zip.ZipException
Message: invalid entry CRC (expected 0x269cdf2c but got 0x13b86fd8)
Location: <expr>:1:1
Huh... maybe notBut even better, maybe we can backport the same patch Arch is using (that is from zlib master branch)
On a positive note, I've now got nix installed again and this time I don't have any issues. Last time it broke my native zsh install
Oh my goodness, it looks like one can't override zlib in an overlay! https://github.com/NixOS/nixpkgs/issues/61682
OK... the way zlib
makes its way into the GraalVM derivation is through mkGraal
: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/graalvm/community-edition/default.nix#L8
And since I can't overlay zlib
, I really have no clue how I can inject it all the way down there without overlaying graalvm
and doing some creative copy and paste.
@UFDRD93RR Do you have any better ideas?
maybe use a flake? I got something here with the help of @UFDRD93RR https://github.com/borkdude/graalvm-nix
you should be using @UFDRD93RR’s version
Oh my, I forgot that I still haven't learned flakes. I think I'm rapidly wading out of my depth here. 😅
I'll wait to see if kokada has any ideas before continuing to bash my head against this wall. 😉
until you can patch zlib, you could just manually download the clj-kondo pod (v2022.05.31) and use an absolute path with load-pod
@UFDRD93RR I guess @U054AT6KT can try your: https://github.com/thiagokokada/nixpkgs/tree/fix-graalvm-zlib fork as his nixpkgs now right, to test this locally?
@UFDRD93RR You’re an absolute legend! I’ll try this out in an hour or two. Today's blog entry is actually all about my fun rabbit hole trying to blog. 😂
@UFDRD93RR This worked, of course! 🏆
Now the next mole to whack: I guess I need to run patchelf
on the pod after downloading it, otherwise this happens:
[jmglov@laurana:~/Documents/code/jmglov.net/blog]$ bb render
Downloading pod clj-kondo/clj-kondo (2021.10.19)
Successfully installed pod clj-kondo/clj-kondo (2021.10.19)
----- Error --------------------------------------------------------------------
Type: java.io.IOException
Message: Cannot run program "/home/jmglov/.babashka/pods/repository/borkdude/clj-kondo/2021.10.19/clj-kondo": error=2, No such file or directory
@U054AT6KT Please update to the newest clj-kondo pod (2022.05.31), that one is fully static and should not need any patching

Well it's a good practice to make pods as static as possible because of these problems
Yikes! highlighter.clj
loads clj-kondo with an explicit version rather than using the one specified in deps.edn
:
(pods/load-pod 'clj-kondo/clj-kondo "2021.10.19")
Is that done for any particular reason? If I leave off the version, will it just load whichever pod is on the "classpath"?@U054AT6KT Are you using a fork of my blog? There's a better way of doing that now
@U054AT6KT You're welcome :) https://github.com/borkdude/blog/commit/edfdcfcb9c4d0b09e27fcb4ab75d24cecda69cb8
It works! http://jmglov.net/blog/
btw clj-kondo pod is only necessary for highlighting, I did it as a home-made solution, but if you don't like this, you can simply use highlight.js which I did before
the idea is you own your own blog code and you can simplify or make it more complex at your convenience
This coming week, I'm going to try to make a custom Lambda runtime for Babashka so I can edit my Babashka stuff in the Lambda console, then port my email over from JDK Clojure to Babashka.
Same for the CSS: I'm not a CSS expert so if you make it more fancy, I might steal some of your ideas
Question about babashka.process
(using the jvm, not bb, don’t know if there’s a better channel?). I have a command that takes a few minutes and I want to run it blocking and print it’s output as it arrives.
I modified a bit the example in the README so it would the recursive loop stops when both the process has finish running (using (.isAlive (:proc p))
and we’ve finished printing it’s output (using (.ready rdr)
).
Is there a simpler way?
(let [p (process ["some-long-command"] {:err :inherit
:shutdown p/destroy})]
(with-open [rdr (io/reader (:out p))]
(binding [*in* rdr]
(loop []
(let [line (read-line)]
(println line))
(when (or (.ready rdr) (.isAlive (:proc p)))
(recur))))))
Oh right, I did want to pre-process the output before printing it, but I think I removed that at some point
In that case, I do need the whole loop right? (like adding a \t
before outputting each line)