babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
Sergio 2021-01-15T10:48:40.023700Z

hello!, is there a guide on how to create a Pod? for example, it’s not clear to me why some pods are written in other languages and how to get one simple “hello-pod” program up and running with Babashka

borkdude 2021-01-15T10:50:09.025Z

@sdmoralesma The docs are available at https://github.com/babashka/pods A hello world pod would be nice to add to the docs. Feel free to create an issue about this. But there are already many clojure examples available, see.: https://github.com/babashka/pod-registry The buddy pod may be the simplest one to look at, since it's just data back and forth, and no real state

❤️ 1
borkdude 2021-01-15T10:51:35.026400Z

Some pods are written in other languages, because low level stuff like file system events are better done in golang or Rust. Some things simply didn't work with GraalVM, like sqlite, so that's why its in golang.

borkdude 2021-01-15T10:52:40.026800Z

One dev tip: you can test the pod first on the JVM using the pod library and/or starting it via ["clojure" "-M" "-m" ...]

borkdude 2021-01-15T10:52:50.027200Z

and if it works, then you can try compiling it to native

Sergio 2021-01-15T10:54:37.027600Z

great!, thank you @borkdude

Sergio 2021-01-15T10:59:11.027700Z

FYI created doc ticket: https://github.com/babashka/pods/issues/28

Marco Pas 2021-01-15T11:52:05.031500Z

Being fairly new to Clojure and Babashka i was wondering how to manage external dependencies. For example if i want to use the environ package i now have this line in my script.

(babashka.deps/add-deps '{:deps {environ/environ {:mvn/version "1.2.0"}}})
(require '[environ.core :refer [env]])
I have another script that also needs this dependency then i need to copy and paste these lines. I read something about a deps.edn file but i am not sure how i can use this to download and use dependencies in my scripts and also being able to use them in my nrepl-server from babashka. Any pointers would be helpfull!!

borkdude 2021-01-15T11:53:31.032Z

Oh wow, environ works with bb :)

(require '[babashka.deps :as deps])

(babashka.deps/add-deps '{:deps {environ/environ {:mvn/version "1.2.0"}}})

(require '[environ.core :refer [env]])

(prn (:path env))
Nice find @marco.pasopas :)

Marco Pas 2021-01-15T11:54:10.032600Z

Not making fun of me 🙂 🙂

borkdude 2021-01-15T11:54:22.033100Z

No, I am serious

borkdude 2021-01-15T11:54:36.033300Z

haven't tried that lib with bb before :)

Marco Pas 2021-01-15T11:54:52.033800Z

Just added it yesterday and sofar no problems..

borkdude 2021-01-15T11:55:41.034900Z

@marco.pasopas So what you can do is add some namespaces to the classpath:

(babashka.deps/add-classpath "script")
(require 'script.deps)
and then move your common deps to script/deps.clj

borkdude 2021-01-15T11:56:19.035500Z

There is no deps.edn or config.edn like file for bb yet. This is something I'm considering, but not there yet.

Marco Pas 2021-01-15T11:56:42.036Z

Thanks for the pointer! Will try it out..

borkdude 2021-01-15T11:56:43.036200Z

This is the issue for it: https://github.com/babashka/babashka/issues/680

Marco Pas 2021-01-15T11:57:10.036900Z

Next thing on my things i want to do with Babashka is unit testing 🙂

borkdude 2021-01-15T11:57:47.037300Z

@marco.pasopas That is very well possible. https://book.babashka.org/#_running_tests

borkdude 2021-01-15T11:59:12.038700Z

I am not sure if bb should use deps.edn itself (or maybe an alias :org.babashka) or that it should have a separate config file, or maybe even a __bb_setup__.clj script that's always run. Feel free to provide feedback in issue 680.

borkdude 2021-01-15T12:01:01.038900Z

babashka_preloads.clj

borkdude 2021-01-15T12:02:39.039400Z

It could be nice to have a .clj file for flexibility and not couple it with deps.edn too much. </hammock>

borkdude 2021-01-15T12:11:34.039600Z

Environ added to projects.md: https://github.com/babashka/babashka/blob/master/doc/projects.md#environ

👍 2
borkdude 2021-01-15T12:34:26.040800Z

@marco.pasopas Btw, I don't think environ adds much for bb except that it reads all envs vars in a nice clojure map. Usually I just use (System/getenv "FOO_BAR")

Marco Pas 2021-01-15T12:35:28.042200Z

@borkdude I agree! In my way to search for a lib that would enable me to set properties using envrionment variables and files i came across this one

borkdude 2021-01-15T12:35:40.042600Z

aah

Marco Pas 2021-01-15T12:36:06.043Z

Just am trying to wrap my head around the clojure world and also babashka

Marco Pas 2021-01-15T12:36:07.043200Z

🙂

borkdude 2021-01-15T12:37:11.044100Z

yeah makes sense, if you are not so familiar with the Java APIs etc these libs can really help

Marco Pas 2021-01-15T13:27:59.045100Z

@borkdude The code

(babashka.deps/add-classpath "script")
(require 'script.deps)
Does the .deps package has a add-classpath?

borkdude 2021-01-15T13:29:17.045600Z

@marco.pasopas no, this is in (babashka.classpath/add-classpath "script")

borkdude 2021-01-15T13:29:27.045800Z

sorry, I made a typo earlier

Marco Pas 2021-01-15T13:29:40.046300Z

No problem 🙂 thought it was my mistake 🙂

Marco Pas 2021-01-15T13:29:47.046700Z

Newbie question 🙂

borkdude 2021-01-15T13:30:00.047Z

but you can also do this in one go with add-deps: {:paths ["script"]} :deps ...}

borkdude 2021-01-15T13:30:11.047300Z

it just takes the contents of a deps.edn file basically

borkdude 2021-01-15T13:33:24.047700Z

If you scroll back to January 12th there is a discussion about this

Marco Pas 2021-01-15T13:51:35.049400Z

So i have created a file called script/deps.clj

(ns deps)

(require '[babashka.deps :as deps])
(babashka.deps/add-deps '{:deps {environ/environ {:mvn/version "1.2.0"}}})
(require '[environ.core :refer [env]])
In my main script…
(babashka.classpath/add-classpath "script")
(require 'script.deps)
Get an error: :message "Could not find namespace: script.deps.

Marco Pas 2021-01-15T13:52:20.049800Z

My problem i guess with not getting clojure that good:)

borkdude 2021-01-15T13:54:04.050300Z

@marco.pasopas No worries. Does it help when you rename (ns deps) to (ns script.deps) ?

borkdude 2021-01-15T13:57:36.050500Z

I will try locally

Marco Pas 2021-01-15T13:59:09.050800Z

I am trying to execute it against a repl

borkdude 2021-01-15T14:02:19.051600Z

ah sorry, I got it..., script is added to the classpath, so everything inside that should be referred as deps.foo without script

borkdude 2021-01-15T14:02:25.051800Z

(require '[babashka.classpath :as cp])
(cp/add-classpath "script")
(require 'deps)

borkdude 2021-01-15T14:02:48.052100Z

and (ns deps) should stay that way

borkdude 2021-01-15T14:03:28.052600Z

you can also add the current dir "." to the classpath, and then you could require it as (require 'script.deps) with (ns script.deps)

borkdude 2021-01-15T14:04:39.053500Z

^ @marco.pasopas

Marco Pas 2021-01-15T14:05:46.053900Z

Gonna give a try! Thanksfor the help!!!!!!!