A small demo how you might leverage fully qualified main functions: https://twitter.com/borkdude/status/1377185155077402627
Any Windows users want to help with this issue? https://github.com/babashka/babashka/issues/766
never mind, figured it out
Babashka shebang in a .bat script works!
I see you use bat
I am trying to get them to respect emacs modelines since they don’t respect bb
on the shebang as clojure
who is them?
.bat file?
or linux? you can use this trick: https://gist.github.com/borkdude/e6f0b12f9352f3375e5f3277d2aba6c9#file-assoc_pairs-clj-L2
no no
yeah, but bat
would use bash
syntax
oh you mean that bat
, I thought you meant Windows .bat
:)
Yeah, funny confusion 🙂
Just upgraded rewrite-clj’s scripts to use bb v0.3.1's bb.edn
, https://github.com/clj-commons/rewrite-clj/commit/7bac58d5bde68b22761d71eaf0592322d1996ace!
If I create a uberjar
or a uberscript
, would my pods be included there as well?
wow, impressive project automation with babashka, this is great to read through
Thanks Nate, I started in bash but have now fully embraced babashka!
Woohoo!
pods are not included as they are platform specific
I see, given target machine is compatible with dev machine, how would you recommend distributing a .bb
script that uses, for instance, the sql pod?
Here’s a ramble-thought. My bb scripts used to fail fast if a they were not being run with a minimum version of bb. This was done as nicety for folks running my bb scripts. Instead of a mysterious failure, they’d get “hey, upgrade your bb, buddy”. I just removed this min version check because it, ironically, it was relying on recent bb features. My question is: Would it make sense for a bb script or maybe bb.edn to somehow specify a min version of bb and fail fast if that version is not met? I realize this would only help bb versions moving forward, so maybe my idea is a bit late.
Oh, that's a great suggestion! I was considering adding something code-wise in bb for it: https://github.com/babashka/babashka/issues/663
but adding this to bb.edn
is probably even better
I also quite like the version-clj library, but this isn't built-in and have people require it just to compare the bb version is a bit too much overhead maybe
(remind's me of a similar config option in Leiningen )
I am surprised more languages don’t offer this kind of check. Or maybe they do, and I am just not aware. I mean backward compatibility is great but it would be nice to effectively say, “yeah, we don’t support forward compatibility, you’ll need to upgrade” instead of failing mysteriously when an old version of tool x tries to access a non-existent new feature.
lein supports it but deps.edn doesn't (yet?)
maybe soon (?) with this new build support coming to clojure cli in the pipes.
I guess in deps.edn you can just say {:deps {org.clojure/clojure {:mvn/version "1.11.0"}}}
and that's your minimum version
does pom.xml
support a min java version?
Oh yeah, I suppose you are right there.
Can’t remember about pom.xml
I think there is something in there about what version you want to compile to.
FWIW I meant this option: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L37
This is maybe a bad idea, but we could (not should) make :min-bb-version
download the min bb version and run the project using that one, so the system bb invokes the needed bb if it's below the minimum
but I guess the first minimal step is just exit with an error
Gradle just wafted into my brain. I think I remember it downloading whatever version the gradle file specifies.
yeah, boot does that too using boot.properties
but both gradle and boot aren't very popular, so maybe that's a bad sign? ;)
Ha! I vaguely remember kinda liking gradle, but I was young and impressionable.
I heard some people get caught up with the DSL and making builds way too complex
I don't have any experience with it myself
Mind you I was coming from maven. So…
I know maven only through clojure, I guess I'm shielded a little bit
Ya, I remember it being convenient - so long as you didn’t want to do anything it does not normally do, then, oh boy!
then use make/bash + XML-generate the pom.xmls? Sounds a bit like what I'm doing now with deps.edn sometimes ;)
From a security perspective you don't want tools to randomly download binaries, just saying
@lukaszkorecki Yeah, I understand from that point of view. I started wondering though: what's the difference with downloading binaries (from a controlled source) or .jar files for that matter? Both can screw up your system, but somehow binaries are often considered more suspicious
Jars are not usually executable, in this case a binary downloads another binary and replaces itself, right?
In some setups machines come with pre-installed stuff, and this approach might not even be an option
Note that pod binaries can now be downloaded automatically from a pod registry when loading them, this was by popular request. The bb binary would not replace the system bb, the system bb would just delegate to the newer one if needed.
I see. Maybe this should be an opt-in?
Yeah, I'm not implementing this in the foreseeable future, just throwing it out here for initial feedback.
:thumbsup:
anyway, :min-bb-version
seems like a good idea for bb.edn
@richiardiandrea if you use (load-pod 'org.babashka/postgresql "0.0.x")
the pod will be automatically downloaded
yeah I am in an environment where I am not likely to access the internet
@lee Just FYI, this pattern exists:
https://book.babashka.org/#main_file
Maybe it comes in handy somewhere in rewrite-clj if you want to prevent side effects when e.g. execute bb doc ...
@richiardiandrea In this case it's better to download the pod(s) yourself and copy them yourself to your artifact/docker image/container
you can load pods also just using a path: (load-pod "./pod-babashka-postgresql")
would just cloning the repo do the job there? (sorry newbie question)
cloning what repo?
oh never mind, i found this https://github.com/eccentric-j/idle-parens/blob/8f4142d66698adadb321ace92da9ed79bbcbcedc/resources/blog/2021-01-27-clojure-like-its-php.md#download--install-babashka-postgresql-pod
yeah @lukaszkorecki I sometimes do work on cljdoc and it has a (probably not well known?) feature where you can download a zipped version of docs for offline viewing. I was thinking this could be a potential vehicle, however unlikely, to get something nasty on somebody’s system, if we aren’t careful.
Cool, thanks, I was going to switch to that convention when/if I switched to vanilla tasks, but I think it is probably worth doing now.
fyi: the pom.xml can support dependency ranges, https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm#MAVEN402
I have an additional question on this one...I have ":/home/cokap/.m2/repository/org/postgresql/postgresql/42.2.2/postgresql-42.2.2.jar"
as result of babashka.classpath/get-classpath
...why can't I (import 'org.postgresql.util.PGobject)
? Am I missing something?
The postgres driver is not part of babashka, it's only part of the pod
do you want to transform something into json or an array?
no unfortunately I have to store a BYTEA
ah, byte array, yeah, in this case you can just send over the byte array directly
and it will be stored automatically as bytea
oh cool! I was worried for a second 😄 let me try that
works flawlessly!
[query "INSERT INTO file_blobs (name, mime_type, byte_size, content) VALUES (?, ?, ?, ?) RETURNING id"
sqlvec [query (:title image) (:mime-type image) (:byte-size image) (Files/readAllBytes (:jpath image))]
inserted-rows (db/execute! db sqlvec)]