Fork me on GitHub

New #babashka release! 1.0.165 (2022-11-01) • Fix mutation of deftype field should be visible in protocol method • Fix drop name metadata from conditionally defined var • add lib tests for clj-commons/fs ( • Add class • Add class • Copy more docstrings for core macros and vars • Bump core.async to 1.6.673 • Implement in-ns as function, rather than special form (@SignSpice) • Bump deps.clj to • Bump GraalVM to 22.3.0 • SCI: don't rely on metadata for record implementation

🎉 5

I’m sure this has come up before but my search-fu is not yielding an answer. I have a ~/bb directory which is quickly amassing general purpose scripts (which I used to use bash or python for). Each script has an “(ns name-of-script …)” form at the start and the (when (= *file* ... snippet at the end. I would like to reuse helper functions defined in these scripts, but for some reason I am not able to (require) any scripts without first running (load-file "name-of-script.clj"). I have a bb.edn in there with {:paths ["."]} but that doesn’t help. Any ideas?


It might help if you add the parent directory of the script to the classpath:

(babashka.classpath/add-classpath (str (fs/parent *file*)))


or you can treat your util functions as a library, by using (babashka.deps/add-deps '{:deps {utils/utils {:local/root "/Users/foo/bb/utils"}}})


The bb.edn is only valid for the working directory you invoke the script from


Unless you use bb --config some-other-bb.edn


Creating a util library and using add-deps definitely works 👍


Couldn’t get the classpath manipulation working (I had tried various combinations of adding the current and parent dirs before as well), but not a big deal



👍 1