Require local Babashka scripts

When writing more involved Babashka scripts, we usually want to extract some common functionality out into library files. Yet there seems to be no established default, where Babashka is looking for those. So if you want to require a lib-namespace, you can set it up like this:

  • Create a (or lib.clj) file; if both exist, the .bb one is used; add (ns lib) to the top.
  • Add . to the class-path.

The later can be done via:

  • Run Babashka with the -cp parameter:
bb -cp .
  • Create a bb.edn file and set :paths:
{:paths ["."]}

Slightly more involved ways can be found in the project setup section of the Babashka docs