Fork me on GitHub
#babashka
<
2023-08-08
>
borkdude09:08:19

Nice blogpost about a script written in bb by @nate! https://endot.org/2023/08/07/highlight/

❤️ 4
🙌 2
socksy10:08:06

I'm trying to recursively list all :local/roots deps using babashka and the https://github.com/babashka/tools-deps-native pod. However I can't work out how to resolve the deps all the way down the tree, which makes me feel like maybe I am using the terminology wrong. E.G when I do:

(require '[ :as io])
(require '[babashka.pods :as pods])
(pods/load-pod 'org.babashka/tools-deps-native "0.1.0")

(require '[clojure.tools.deps :as deps])

(prn (deps/resolve-deps (:deps (deps/slurp-deps (io/file "deps.edn"))) {}))
The printed out result does not have the recursive dependencies of the projects in those dependencies. Is there an easy way to get them?

borkdude10:08:02

perhaps try to repro with tools.deps on the JVM first, if it behaves the same I think it's a #C6QH853H8 question, if not, then we can see why it behaves differently

socksy10:08:30

i guess i'm a bit confused what the org.babashka/tools-deps-native pod is doing — it doesn't seem to be providing all of tools.deps, right?

borkdude10:08:20

the tools-deps-native pod wraps tools.deps indeed. and it offers support for https://github.com/babashka/tools.bbuild which is tools.build made compatible with babashka, this uses the pod

borkdude10:08:49

I don't know if tools-deps-native offers ALL of tools.deps, but it does offer what is used by tools.bbuild

borkdude10:08:24

there is a new version of the pod btw, 0.1.1, I recommend using that one instead

👍 2
socksy10:08:14

gotcha. I had tried (require '[clojure.tools.deps.tree :as deps.tree]) to find out it wasn't provided, so I assumed that somewhere there's a subset being defined — I just don't know how to read that code though

socksy10:08:48

oh wow lol I updated to 0.1.1 and now deps/create-basis works and I can see the subdeps

respatialized15:08:44

Is there a bb-compatible elisp parser?

borkdude15:08:35

I don't think so, but perhaps you can just use edamame? since elisp is basically just s-expressions without weird notation... right?

borkdude15:08:50

there is a clj 2 elisp compiler toy project here: https://github.com/borkdude/clj2el

borkdude15:08:36

This worked for parsing my home config at least:

(e/parse-string-all (slurp "/Users/borkdude/.emacs.d/personal/init.el") {:all true})

Matthew Twomey16:08:52

I’m looking to create a babashka script that: 1. Opens an ssh tunnel to a remote (jump) host 2. Establishes a mysql connection over that tunnel (essentially to 127.0.0.1:3306) 3. Do SQL stuff 4. Close everything down Searching a bit in this channel, it’s not quite clear to me what the preferred approach to to this would be for the SSH part?

Matthew Twomey16:08:11

Aha, ok that does look like it’s what I want. Will confirm back.

nate16:08:34

Please do, I'm curious about it as well

Matthew Twomey20:08:47

@UCK2PHQ59 Confirmed. This works just fine and is easy to manage.

nate20:08:38

awesome, thank you

👍 2
Dig16:08:55

anybody using bb to drive k8s api? tried https://github.com/nubank/k8s-api/tree/master but failed on loading less-awful-ssl with unable to resolve classname java.security.Key

james17:08:35

I use bb to drive kubectl -o json and it works well for me.

Dig17:08:38

yes, i did the same thing, was wondering if there is more direct way

borkdude17:08:55

we could try to add this class, but it would be best to try with a local copy of babashka and run it through a JVM to see what other classes are missing

borkdude17:08:40

you can add classes in src/babashka/impl/classes.clj

jeroenvandijk17:08:10

FYI, I created a simple library to mimick Babashka in the Clojure repl https://github.com/jeroenvandijk/babashka-clj

👍 2
borkdude17:08:44

If you are relying on people to use clojure 1.12 I'd recommend that you would shell out to babashka and call bb print-deps which prints built-in dependencies AND dependencies from bb.edn and add that dynamically to your REPL

borkdude17:08:13

then you wouldn't have to update your deps.edn

borkdude17:08:21

and it would resemble what bb has on their system

jeroenvandijk17:08:28

hmmm yeah I’ll give that a try too. The deps are generated with bb print-deps btw (https://github.com/jeroenvandijk/babashka-clj/blob/main/dev/src/generate.cljc#L23). One argument against shelling out is that the bb dependencies might change overnight. But depends of course, if you want to be in sync with Babashka this might be the better option

borkdude17:08:03

isn't the point that you would run the script with bb in the end? then it would be better to discover those dep changes sooner than later I guess

jeroenvandijk17:08:42

I would get a bit paranoid if it doesn’t work after an update and it’s not clear that it is because of an update of Babashka, but yeah maybe. I’m just getting this library out the door after a few times copy pasting the deps. Not sure what I’ll like better yet

jeroenvandijk17:08:50

Thanks for the feedback either way of course

👍 2
borkdude17:08:56

user=> (require '[clojure.repl.deps :as repl-deps])
nil
user=> (require '[clojure.java.process :as proc])
nil
user=> (def bb-edn-deps (clojure.edn/read-string (proc/exec "bb" "print-deps")))
#'user/bb-edn-deps
user=> (repl-deps/add-libs (:deps bb-edn-deps))
...
user=> (require '[babashka.fs :as fs]) ;; works!

❤️ 2
borkdude17:08:56

user=> (require '[clojure.repl.deps :as repl-deps])
nil
user=> (require '[clojure.java.process :as proc])
nil
user=> (def bb-edn-deps (clojure.edn/read-string (proc/exec "bb" "print-deps")))
#'user/bb-edn-deps
user=> (repl-deps/add-libs (:deps bb-edn-deps))
...
user=> (require '[babashka.fs :as fs]) ;; works!

❤️ 2
Matthew Twomey20:08:10

I’m looking for a bcrypt solution for hashing a password that works in babashka. Any thoughts?

borkdude20:08:41

either use the builtin crypto Java classes or if they aren't available, try the buddy pod

Matthew Twomey20:08:36

Ok, thanks for the pointer.