Fork me on GitHub

Very nice! > There’s still more to do on the Babashka support, in particular this release doesn’t do anything at all with bb.edn. So if you’re adding extra dependencies via that those won’t work for the moment, and there’s no task running support yet either. Note that print-deps will also output the deps in bb.edn


Oh, interesting. Does that require bb to be run in the directory containing bb.edn? I assume so.


Currently a project-wide lib is created, but I actually think that’s not the right approach, especially given that information.


yes, bb.edn is picked up from the current working dir


Ok. The only time anyone would see weirdness right now is if they have a large project with multiple bb.edn files and different dependencies in each one.


but hey, this is already a major improvement, let's wait for the feedback


What people can also do is using print-deps manually, create a deps.edn, develop as if normally on the JVM and then run the script with bb again when ready


(if all else fails)


of course the integrated experience is much nicer


clojure-lsp will also release a version today which leverages this new feature for better analysis

Mikey OBrien14:08:28

Is it possible for tasks to be discoverable from within project subdirectories?


I’m doing something similar. heres my script

#!/usr/bin/env bb

(require '[ :refer [sh]]
         '[clojure.string :as str]
         '[babashka.fs :as fs]
         '[babashka.process :as p :refer [process check]])

(defn find-up [target]
  (let [here (:out (sh "pwd"))]
    (loop [parents (iterate fs/parent here)]
      (if-let [dir (first parents)]
        (let [dir-str (str (str/trim (str dir)) "/bin")
              local-files (set (str/split-lines (:out (sh "ls" dir-str))))]
          (if (contains? local-files target)
            (recur (rest parents))))
        (throw (ex-info "Not found." {:target-file target}))))))

(let [cmd (into ["bb"] (or *command-line-args* ["tasks"]))
      p (process cmd {:dir (find-up "bb.edn")
                  :in :inherit})]

  (when ((into {} System/getenv) "DEBUG")
    (println "==================================================")
    (println "cmd:" (pr-str cmd))
    (println "dir:" (find-up "bb.edn"))
    (println "=================================================="))

  (binding [*in* (io/reader (:out p))]
    (loop []
      (when-let [x (read-line)]
        (println x)

👍 2

I put that into a file called b

🙌 3

@hmobrienv Currently bb only takes into account the bb.edn in the current working dir


Support for explicit bb.edn file would allow both to run the tasks from anywhere and also to have different sets of tasks like admin-tasks.edn and dev-tasks.edn for different usages on the project. bb --conf ~/prj1/bb.edn run test


@U1LG6HNMT The question here is: should --conf ... take into account the relative sources the current working directory, or from the config directory


What will the classpath look like?


I think that the conf file might be the pivot. It will be relative to its location. I guess that explicit root would also be useful, maybe on the bb.edn to be able to override the default of conf file location. would that make sense?


@U1LG6HNMT I think there is a discussion about this exact topic here: Could you please leave your feedback there? Then we can collect all the data to make good decisions.


@hmobrienv You can invoke a command in a subdirectory from the top level bb.edn though, if that is your use case


(shell {:dir "subdir"} "do stuff")

Mikey OBrien15:08:58

I do a lot of work with Terraform so i’m rarely in project roots but have some complicated manual processes to build dependencies i’d like reachable anywhere. I suppose I can go the invoking commands in a subdirectory route. Thanks!


I'm considering forking tools.deps.alpha and ripping everything out but gitlibs and then see if that can be included in bb itself. That code should be relatively thin. And then the trade-off will be: use only (transitive) git libs and don't need Java for deps (only a git install), or use clojars/maven libs and then "pay" some Java startup time... I will then also attempt to port the git libs stuff to .cljc so it can be used on node (for #nbb)

💯 5
agu monkey17:08:39

I tried building babashka 0.5.1 (using the website tutorial) and the resulting jar takes 7 seconds to boot, did I miss something ?

Mikey OBrien17:08:24

Is there an option to suppress task output?


Yes, you can direct to /dev/null for example using (shell {:out "/dev/null"} ...)


@agu.monkey The jar is not yet the binary

agu monkey18:08:05

ok after letting my cpu overheat I finally get the snappiest ./bb thanks a ton (and massive congrats for assembling babashka, quite a gem)


Naming is hard, how do you call the folder where all the "shareable"/"model" code resides? I am thinking of extrapolating things for babashka scripts to use that are not related to database and all that. These are the actual domain pure functions...kind of like having .cljc files for ClojureScript



❤️ 3

yeah I was thinking about domain - I just don't want to go for lib or shared cause they give small info to the reader