Fork me on GitHub
#babashka
<
2022-01-18
>
murtaza10:01:08

I wonder if I'm overlooking something very obvious, but so far I haven't been able to figure out what that may be. When I try to eval an ns (specifically the main ns) using a repl started with a cider-jack-in, I see a YAMLException:

Syntax error (ClassNotFoundException) compiling at (src/babashka/main.clj:1:1).
org.yaml.snakeyaml.error.YAMLException
ERROR: Unhandled REPL handler exception processing message {:nrepl.middleware.print/stream? 1, :nrepl.middleware.print/print cider.nrepl.pprint/pprint, :nrepl.middleware.print/quota 1048576, :nrepl.middleware.print/buffer-size 4096, :nrepl.middleware.print/options {:right-margin 70}, :op stacktrace, :session e6516ced-649d-48c9-8b1e-55f1a86e5c71, :id 12}
java.lang.NoClassDefFoundError: Could not initialize class babashka.impl.classes__init
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:398)
	at clojure.lang.RT.classForName(RT.java:2212)

borkdude10:01:02

Do you have a reproduction?

borkdude10:01:45

Is this using the binary version of babashka?

borkdude10:01:26

The binary?

borkdude10:01:12

The thing you download to get the fast startup time: https://github.com/babashka/babashka/releases/tag/v0.7.3

borkdude10:01:51

With reproducing I mean: reproducable for me or anyone else who would take a look at the issue. Detailed instructions how to get the error, step by step.

borkdude10:01:53

but if you are using lein repl , then you are not using the binary version, you are using the JVM.

borkdude10:01:46

no, it means, just bb on the command line.

borkdude10:01:27

ah I see, so you are trying to develop babashka?

borkdude10:01:21

I recommend starting it with lein with-profiles +test repl The it will include all the dependencies

borkdude10:01:26

We should probably update this

borkdude10:01:50

Or you can use clojure -M:cider-nrepl instead where cider-nrepl is an alias for cider

ordnungswidrig10:01:42

Would it make sense to try to get babashka running on more restricted JS environments? Thinking of espruino or other embedded devices JS implementations. Or is this rubbish "cross-compilation" of clojurescript to minimized JS is the best option? :thinking_face:

Adam Helins15:01:44

Naive question here, but would the espruino be tough enough to support that kind of "double interpretation"? Interpreting JS which interprets Clojure (via SCI)

borkdude10:01:30

@ordnungswidrig We have #nbb and #obb for getting SCI to run on JS hosts. We could certainly make one for espruino.

borkdude10:01:58

babashka itself isn't using JS at all.

borkdude11:01:20

The babashka AWS pod, based on cognitect/aws-api, was updated to the newest release - includes a fix for new services like proton. v0.1.2: https://github.com/babashka/pod-babashka-aws/blob/main/CHANGELOG.md#v012 Thanks @jeroenvandijk

jeroenvandijk15:01:11

@U04V15CAJ You’re welcome and thank you too!

mknoszlig16:01:06

when playing around with task definitions and trying to find a good balance of what should go into bb.edn and what should live in a .clj file, i noticed that using functionality that depends on reader macros such as #() @ in the edn file throws an error. i don’t think this needs to be supported (imo one goal for task defs should be to do as little as possible) but it might make sense to mention that fact in the book somewhere. worth filing an issue?

borkdude16:01:32

My convention lately is to use {:paths ["bb"]} and then put the bb scripts in $project/bb

borkdude16:01:41

and then require that in tasks

borkdude16:01:40

all things like #(...) and @(...) can be written as (fn ...) and (deref ...) so there is always a solution for this

mknoszlig16:01:52

in my current case the whole project is just a collection of tasks backed by some code so atm everything is just in the base dir, but i like that convention because it works in larger projects as well

borkdude16:01:56

but the error messages may surprise users

mknoszlig16:01:47

yeah, eg using #() gives me

> bb tasks
Exception in thread "main" java.lang.RuntimeException: No dispatch macro for: (
	at clojure.lang.Util.runtimeException(Util.java:221)

borkdude16:01:00

I'm also considering making linting for bb.edn - if you want to take a stab at that in clj-kondo, certainly welcome. One thing I want to lint is that every :depends name is also a task name

borkdude16:01:11

Also clj-kondo could warn about the things above

borkdude16:01:16

in general in .edn files

mknoszlig16:01:23

having linting for bb.edn certainly makes sense

mknoszlig16:01:37

hm, doesn’t it depend on how you read the edn files?

borkdude16:01:14

it's always disallowed to use #(...) in .edn files.

mknoszlig16:01:40

i see, my bad then 🙂

borkdude16:01:53

unless you use a clojure reader to parse .edn files, but that doesn't match with the EDN specification

mknoszlig16:01:40

iirc you can provide reader tags (for eg stuff like #inst ) but that’s probably not relevant for #()

mknoszlig16:01:07

ok, got that mixed up i guess 😄

borkdude16:01:21

#fn (inc %), we could support that, but I don't know if that's worth it ;)

mknoszlig16:01:42

probably not 🙂

mknoszlig16:01:54

btw, i came across babashka.fs.unzip - is there a reason there’s no babashka.fs.zip or just that no one has had the need to implement it yet?

borkdude16:01:55

yes, I want to have that, but I have to think about the API... :) probably I'll be looking at the implementation in tools.build

borkdude16:01:10

the tools.build implementation already works today in babashka, when you copy it

mknoszlig16:01:55

that’s great to know, thanks! this is the one point where i had to distinguish between osx/linux and windows in my current little project

mknoszlig16:01:46

so far, the portability experience between platforms is really neat