This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-20
Channels
- # adventofcode (1)
- # announcements (2)
- # babashka (81)
- # beginners (33)
- # calva (11)
- # circleci (4)
- # clj-commons (3)
- # cljdoc (7)
- # clojars (5)
- # clojure (21)
- # clojure-europe (5)
- # clojure-japan (1)
- # clojure-norway (27)
- # clojurescript (24)
- # emacs (11)
- # events (5)
- # fulcro (14)
- # lsp (40)
- # malli (9)
- # nbb (1)
- # off-topic (5)
- # portal (4)
- # reitit (8)
- # scittle (9)
- # shadow-cljs (14)
- # spacemacs (3)
- # tools-deps (3)
@borkdude You may like this talk, in case you are thinking of Babashka on WebAssembly at some point. Given by guy who worked on V8 at Google. https://youtu.be/P_7ptIBg4PY
Can Babashka run Kaocha? If so, how do I start it with a Task? I have a deps.edn that includes
;; deps.edn
{...
:aliases {...
:test {:extra-paths ["test"]
:extra-deps {lambdaisland/kaocha
{:mvn/version "1.71.1119"}
...}}
:runner {:main-opts ["-m" "kaocha.runner"]}}}
And a bb task that runs a test suite through Clojure,
;; bb.edn
{...
test-clj (clojure "-M:test:runner" "clj")}
which I run with bb test-clj
.
How do I run the same test suite, but in Babashka instead of Clojure? (The point being to verify Babashka compatibility.)You can try it like this: bb.edn
{:deps {lambdaisland/kaocha {:mvn/version "1.71.1119"}
org.babashka/spec.alpha {:git/url ""
:git/sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}}
}
bb -m kaocha.runner
I came across one missing class: java.lang.Error
- I'll add that to bb.
Continuing with bb master:
clojure -M:babashka/dev -m kaocha.runner
Type: java.lang.Exception
Message: Unable to resolve classname: clojure.lang.DynamicClassLoader
----- Stack trace --------------------------------------------------------------
dynapath.defaults - dynapath/defaults.clj:4:3
dynapath.util - dynapath/util.clj:3:3
kaocha.classpath - kaocha/classpath.clj:5:3
kaocha.testable - kaocha/testable.clj:3:3
kaocha.plugin.capture-output - kaocha/plugin/capture_output.clj:2:3
kaocha.report - kaocha/report.clj:92:3
kaocha.config - kaocha/config.clj:2:3
kaocha.api - kaocha/api.clj:4:3
kaocha.runner - kaocha/runner.clj:5:3
user - <expr>:1:10
It seems kaocha is doing stuff with classloaders. Not sure why, but in bb this doesn't workkaocha is quite a complex project. If you can't get it to work, I recommend running the cognitect test runner which works with bb today
Thx. So master has java.lang.Error now? I'll give it a try. Pretty sure I read something in the Koacha docs about disabling the classloader stuff.
Ran the script to install bb master, and still see java.lang.Error
missing.
I found the info about Koacha's ClassLoader. It is there to allow the option of specifying test source paths in test.edn
instead of deps.edn
. It is easily disabled with a config option on the test suite.
;; test.edn
#kaocha/v1
{:tests [{:id :unit
:skip-add-classpath? false}]}
you should get it from https://github.com/babashka/babashka/blob/master/resources/BABASHKA_VERSION
😞 First try, it is still crashing on code about the ClassLoader. Hopefully I am just misunderstanding where/how to specify the config option. Otherwise, I guess I'll file an issue with Kaocha, and hope. Then use cognitect in the meantime.
You could try asking in the #CCY2V0U6A channel too?
Custom build of bb with DynamicClassLoader class, just to see how far I can get when importing doesn't break, and .. Crashed again, on code still trying to do ClassLoader shenanigans, despite my config saying "don't do that". 😒
@U90R0EPHA To make progress on this, it's probably best to run with a local checkout of kaocha and remove stuff that works around the classloader stuff
I'm getting many files like .babashka-pod-2027225.port
in my project root where my bb.edn lives. Not sure where it comes from. Is there some explanation of these somewhere? Or a guess of why they might be hanging around?
Yes, it is that, but is it normal that they're hanging around like this, or does it indicate some problem in my setup?
The polite thing to do is mark those files as deleteable when the vm exits. If you have any processes running, stop them and see if the files remain. If so you should raise an issue I think
@UPWHQK562 which pod causes this?
I think it's {epiccastle/spire {:version "0.1.1"}}
, but I know I should be moving to https://github.com/epiccastle/bbssh, so maybe it's a moot point... just haven't had the time to upgrade yet.
Perhaps make an issue there : the way it should be implemented is: when their process shuts down, they should remove the file. Indeed what @U11BV7MTK says: mark it as delete on shutdown
Okay, so it's definitely an irregularity then. Alright, I'll try to confirm/get more detail about it and will report. Thanks, all.
There is a shutdown hook to delete it. I wonder why its not working? https://github.com/epiccastle/spire/blob/master/src/clj/spire/pod/core.clj#L105-L108 :thinking_face:
I will do some testing thanks @UPWHQK562
you can do this instead maybe: https://github.com/babashka/fs/blob/master/API.md#babashka.fs/delete-on-exit
if you implement the "shutdown"
operation, then the pod is shutdown more gracefully, might also help
This is the pod mainline, not running in babashka. I thing shutdown operation will be the best thing.
Thanks for checking this out, @U1QQJJK89. Not sure if you've concluded this, but just FYI, I updated the repro to use (pods/load-pod 'epiccastle/spire "0.1.2")
and I'm still getting the port files left over in my directory after the process is done.
@UPWHQK562 ah damn. Was working when running the pod under JVM. But as graal native-image binary deleteOnExit
doesn't work. I've come up with something now that seems to work with native image to. I will re-tag and release 0.1.2. Hold on.
it could be that in a shutdown that is forced, the delete on exit doesn't have time to execute
but what Im doing now is deleting it after socket is established, while its still running
ok, that should work too... still weird that the shutdown op didn't work, it should.
yeah... something strange going on. And it worked on JVM which is doubley strange. Don't have time to dig in atm. This early delete seems to work for now.
yes, you need to declare it in your describe message that you implement the shutdown op. RTFM dude ;)
"If the pod does not support the shutdown op, the pod process is killed by the pod client"
that explains it. It's nuking it before it can do anything. Wow, reading is quite useful, hey 😄
> The optional ops
value communicates which ops the pod supports, beyond describe
and invoke
. It is a map of op names to option maps. In the above example the pod declares that it supports the shutdown
op.
probably the pods thing can also remove the file after it connects, this seems more reliable than asking people to do this
and when it doesn't exist anymore, that won't crash either I think so it will be a double safety measure
yeah. I will test .delete
ing a non existent file and if there is no exception then I could patch bb to delete it after connection
I think just marking it as delete on exit in bb will be sufficient, not actually deleting it
alright, got the shutdown message calling me. and file deleted nicely from that message. 🎉
@UPWHQK562 I have rebuilt and rereleased 0.1.2 with a working file cleanup. You will need to delete your local pod repository ~/.babashka/pods/repository/epiccastle/spire/0.1.2/
to have babashka fetch the new 0.1.2 binary.