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
@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
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.
One dev tip: you can test the pod first on the JVM using the pod library and/or starting it via ["clojure" "-M" "-m" ...]
and if it works, then you can try compiling it to native
great!, thank you @borkdude
FYI created doc ticket: https://github.com/babashka/pods/issues/28
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!!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 :)Not making fun of me 🙂 🙂
No, I am serious
haven't tried that lib with bb before :)
Just added it yesterday and sofar no problems..
@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
There is no deps.edn or config.edn like file for bb yet. This is something I'm considering, but not there yet.
Thanks for the pointer! Will try it out..
This is the issue for it: https://github.com/babashka/babashka/issues/680
Next thing on my things i want to do with Babashka
is unit testing 🙂
@marco.pasopas That is very well possible. https://book.babashka.org/#_running_tests
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.
babashka_preloads.clj
It could be nice to have a .clj file for flexibility and not couple it with deps.edn too much. </hammock>
Environ added to projects.md: https://github.com/babashka/babashka/blob/master/doc/projects.md#environ
@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")
@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
aah
Just am trying to wrap my head around the clojure world and also babashka
🙂
yeah makes sense, if you are not so familiar with the Java APIs etc these libs can really help
@borkdude The code
(babashka.deps/add-classpath "script")
(require 'script.deps)
Does the .deps package has a add-classpath?@marco.pasopas no, this is in (babashka.classpath/add-classpath "script")
sorry, I made a typo earlier
No problem 🙂 thought it was my mistake 🙂
Newbie question 🙂
but you can also do this in one go with add-deps: {:paths ["script"]} :deps ...}
it just takes the contents of a deps.edn file basically
If you scroll back to January 12th there is a discussion about this
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.
My problem i guess with not getting clojure that good:)
@marco.pasopas No worries. Does it help when you rename (ns deps)
to (ns script.deps)
?
I will try locally
I am trying to execute it against a repl
ah sorry, I got it..., script is added to the classpath, so everything inside that should be referred as deps.foo
without script
(require '[babashka.classpath :as cp])
(cp/add-classpath "script")
(require 'deps)
and (ns deps)
should stay that way
you can also add the current dir "." to the classpath, and then you could require it as (require 'script.deps)
with (ns script.deps)
Gonna give a try! Thanksfor the help!!!!!!!