Fork me on GitHub
#babashka
<
2023-12-22
>
Michael W06:12:01

Is java.util.LinkedList not available in babashka? I am trying to use https://github.com/wkok/openai-clojure in babashka but it is complaining about java.util.LinkedList not being resolvable.

borkdude09:12:01

I'll have a look in an hour

borkdude12:12:29

sorry, was distracted with other issues, gonna look now

borkdude13:12:50

This library seems to depend on implementation details of core.async: [clojure.core.async.impl.protocols :as impl] Is that sse.clj namespace necessary to your goals?

borkdude13:12:08

when checking out the dependency locally and commenting out the sse namespace I'm able to load it:

$ bb --config deps.edn -e "(require '[wkok.openai-clojure.api :as api])"

borkdude12:12:20

PSA: If you were using data.json in bb, 2.4.0 was the last working working. In 2.5.0 definterface is used which is not supported in SCI/bb. To make JSON code compatible with bb either use macros (if-bb ...) , reader conditionals or use https://github.com/babashka/json.

leifericf13:12:44

I have created https://gist.github.com/leifericf/242fb222966c8cfc8beb04539aaf8fab. Maybe it's helpful to someone. It's not using Babashka-specific things, but I developed it with- and for Babashka and ran it there.

👍 1
1
John Doe14:12:29

https://github.com/babashka/cli/issues/12 Trying to write a cli program in bb cli, pretty standard subcommand pattern mycli subcommand --option=foo Is there any example on how can I auto generate help for both subcommands and opts? All I can find is example to generate help for opts, but not subcommands?

borkdude14:12:52

This isn't implemented yet

John Doe14:12:24

ah..I saw the issue is marked as complete, so just double check here

borkdude14:12:10

If you have a proposal how it should be implemented, happy to add it, but I think there is no one right way to do it

borkdude14:12:59

right now I just do it manually for the subcommands and I use the option formatting for options

John Doe14:12:14

i don't think there'll ever be a general solution that can fit all werid edge cases. but i'd expect just to write a subcommand table with each command's opts' spec attached, then it'd gave me what you hand crafted for neil there..(maybe a plus one spec for global options)

borkdude14:12:48

I expect something like this to land in the next few months, I'm working on some other part of cli first

👍 2
Noah Bogart16:12:18

What’s the reason bb doesn’t support definterface?

borkdude16:12:01

Because definterface creates a new Java interface. bb can't create any new classes.

borkdude16:12:14

defprotocols in theory also creates a new class, but bb fakes this

borkdude16:12:14

could it fake the interface too? maybe, I tried it briefly but ran into some corner cases

borkdude16:12:17

with some more effort,

0 failures, 25 errors.
{:test 233, :pass 171, :fail 0, :error 107}
only 25 errors left with data.json 2.5.0 :/

😅 1
Noah Bogart16:12:26

Dang, that’s a bummer

Noah Bogart16:12:33

I’m surprised that it’s harder to fake the class/interface than for a protocol

borkdude16:12:32

This is actually not about the definterface anymore but about doing direct JVM interop on a deftype rather than going through a protocol

borkdude16:12:49

oh no, it does have to do with definterface since you don't have a protocol in that case :)

borkdude17:12:11

let's see if I can fix this

🙏 1
borkdude19:12:11

If the definterface was a defprotocol, there wouldn't have been a problem but I think the goal was to squeeze the last bit of performance out of this or so...

👍 1
borkdude19:12:26

This is getting way too complicated, I think I'm just not going to support this

Noah Bogart19:12:03

Damn, okay. Thanks for looking

borkdude19:12:22

Why were you interested in this btw?

Noah Bogart19:12:12

The conversation in data-json intrigued me, which is why i asked. I have no use case myself lol

Noah Bogart19:12:42

It’s a small incompatibility I’ve noticed before but never dug into

borkdude19:12:15

one of the things that makes it harder than protocols is with protocols you can see which namespace a protocol method comes from

👍 1
borkdude19:12:50

perhaps I could do one last attempt via the type hint stuff: if the type hint is a (fake) interface, the Java interop should be interpreted as a method call on that interface... perhaps

borkdude19:12:05

maybe when I feel a little more energized ;)

👍 1
Noah Bogart19:12:25

lol no worries, you don’t owe me anything here. I’m always surprised and impressed by what you pull off that looks impossible

😅 1
Alex Miller (Clojure team)21:12:25

I tried to install babashka on an m1 mac using brew and failed

$ brew install borkdude/brew/babashka
Warning: No available formula or cask with the name "borkdude/brew/babashka".
I was able to brew tap borkdude/brew just fine, and I can see the formula there, so wondering if this something architecture related

borkdude22:12:42

on an m1:

$ brew install borkdude/brew/babashka
Warning: borkdude/brew/babashka 1.3.186 is already installed and up-to-date.
To reinstall 1.3.186, run:
  brew reinstall babashka

borkdude22:12:04

and:

$ brew reinstall borkdude/brew/babashka
==> Fetching borkdude/brew/babashka
==> Downloading 
Already downloaded: /Users/borkdude/Library/Caches/Homebrew/downloads/16be32333058ff4062d771022c51a44b5f523ae09e3d114ee2929a2dc1ace564--babashka-1.3.186-macos-aarch64.tar.gz
==> Reinstalling borkdude/brew/babashka
🍺  /opt/homebrew/Cellar/babashka/1.3.186: 3 files, 63.7MB, built in 2 seconds

Alex Miller (Clojure team)22:12:05

kind of suspecting my brew might be faulty - this machine was copied from an intel machine backup, going to reinstall brew

borkdude22:12:11

no problem!

Alex Miller (Clojure team)22:12:31

now to just figure out everything I need to reinstall :)

borkdude22:12:56

do you still have your intel installation around?

Alex Miller (Clojure team)22:12:41

well, maybe? I don't know, might be in a closet somewhere, don't even remember

borkdude22:12:03

you could run brew list on there, but usually I just wait until I need something and then install it again, lazy evaluation ftw

1
Alex Miller (Clojure team)22:12:23

oh, I did actually do that before I reinstalled :)

ericstewart18:12:48

a Brewfile can be handy for this too, but something else to remember to maintain or dump before you really need it https://github.com/Homebrew/homebrew-bundle

pesterhazy13:12:25

I've seen so many problems due to x86->arm brew migration. Completely uninstalling brew is often the best fix