This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-02-06
Channels
- # aleph (43)
- # announcements (11)
- # babashka (35)
- # beginners (70)
- # calva (4)
- # cider (8)
- # clerk (15)
- # clojure (192)
- # clojure-australia (1)
- # clojure-dev (7)
- # clojure-europe (44)
- # clojure-nl (2)
- # clojure-norway (64)
- # clojure-uk (4)
- # code-reviews (4)
- # conjure (1)
- # cursive (41)
- # data-science (1)
- # datomic (8)
- # emacs (7)
- # fulcro (13)
- # humbleui (17)
- # hyperfiddle (53)
- # kaocha (4)
- # malli (7)
- # missionary (17)
- # music (1)
- # obb (1)
- # off-topic (8)
- # polylith (1)
- # portal (3)
- # releases (11)
- # shadow-cljs (36)
- # squint (4)
- # tools-deps (4)
I’m extending this https://book.babashka.org/#_pods_in_bb_edn like so:
(ns my-project.db
(:require [pod.babashka.go-sqlite3 :as sqlite]
[babashka.fs :as fs] :reload)) ;; <-- added
(defn -main [& _args]
(prn (sqlite/query ":memory:" ["SELECT 1 + 1 AS sum"])))
Now running bb -m my-project.db
fails like it does when not having the :pods {,,,}
in bb.edn.$ bb -m my-project.db
----- Error --------------------------------------------------------------------
Type: java.io.FileNotFoundException
Message: Could not locate pod/babashka/go_sqlite3.bb, pod/babashka/go_sqlite3.clj or pod/babashka/go_sqlite3.cljc on classpath.
Location: /Users/gert/projects/playground/bb/pods/bb/my_project/db.clj:2:3
----- Context ------------------------------------------------------------------
1: (ns my-project.db
2: (:require [pod.babashka.go-sqlite3 :as sqlite]
^--- Could not locate pod/babashka/go_sqlite3.bb, pod/babashka/go_sqlite3.clj or pod/babashka/go_sqlite3.cljc on classpath.
3: [babashka.fs :as fs] :reload))
4:
5: (defn -main [& _args]
6: (prn (sqlite/query ":memory:" ["SELECT 1 + 1 AS sum"])))
----- Stack trace --------------------------------------------------------------
babashka.main/exec/fn--32207/load-fn--32218 - <built-in>
my-project.db - /Users/gert/projects/playground/bb/pods/bb/my_project/db.clj:2:3
user - <expr>:1:10
~/projects/playground/bb/pods
$ tree -C
.
├── bb
│ └── my_project
│ └── db.clj
└── bb.edn
2 directories, 2 files
without :reload
it works fine.
Bug?What is btw the underlying reason a reload of a pod fails? Looking at the error it seems it’s not ‘really’ on the classpath(?)
I found it somewhat confusing how clojure
works from inside a bb task vs how deps/clojure
from a bb script does: (running https://github.com/babashka/babashka/blob/68e8ac6e10c86650c191431b26c64b6966002bd7/src/babashka/deps.clj#L25)
; bb -e "(-> (deps/clojure '[-M -e (+ 1 2 3)] {:out :string}) deref :out println)"
6
; bb -Sdeps '{:tasks {example (-> (clojure \'[-M -e (+ 1 2 3)] {:out :string}) deref :out println)}}' example
WARNING: Implicit use of clojure.main with options is deprecated, use -M
Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
[-M (No such file or directory)
Full report at:
/var/folders/sw/hg9d03hs7w50dfrhmxb4v6w00000gn/T/clojure-17864798851295072450.edn
Error while executing task: example
; bb -e '(-> (deps/clojure {:out :string} \'[-M -e (+ 1 2 3)]) deref :out println)'
WARNING: Implicit use of clojure.main with options is deprecated, use -M
Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
[-M (No such file or directory)
Full report at:
/var/folders/sw/hg9d03hs7w50dfrhmxb4v6w00000gn/T/clojure-11961317677263333737.edn
It doesn't seem to work in this caseThe doc I found is here: https://github.com/babashka/babashka/blob/68e8ac6e10c86650c191431b26c64b6966002bd7/src/babashka/deps.clj#L25
By "old way" you also mean the '[-M -e (+ 1 2 3)]
part, right? That should now be passed as individual args if I see it correct
This is the recommended way:
$ bb -Sdeps "{:tasks {example (-> (clojure {:out :string } \"-M\" \"-e\" \"(+ 1 2 3)\") deref :out println)}}" example
6
I mean, what's the problem statement now: docstring should be altered, or old behavior should be fixed?
I was going to suggest a doc update. Old way still works with -e
. New way works from both. Mixed way (clojure {:out :string} '[-M -e (+ 1 2 3)])
doesn't work from either.
Not sure If I understood the question, but there's https://github.com/borkdude/jayfu which is a CLI built with graalvm and babashka
close but not quite. So @U04V15CAJ has shown you can cat the bb binary and a bb uberjar into a binary that runs.
I currently do bb cmd, copy the text and run that. I would love to break that down into individual tasks
{:paths ["src"]
:require [[babashka.process :refer [shell process exec]]]
:tasks {status (shell “git” “status”)
cmd (println “bb uberjar foo.jar -m foo && cat ./bb foo.jar > foo && chmod +x ./foo && ./foo”)
compile {:doc “Compile”
:task (shell “bb” “uberjar” “foo.jar” “-m” “foo”)}
release {:doc “Release”
:task (do (shell “cat” “./bb” “foo.jar” “>” “foo”)
(shell “chmod” “+x” “./foo”))}
run {:doc “Run”
:task (shell “./foo”)}}}