Fork me on GitHub

Looks like there are more and more wonderful libraries in Clojure, most of them provide a main function that can start with -M . I wonder whether it's possible to start multiple main functions in a single repl, or I have to write a .clj script to combine them.

Alex Miller (Clojure team)14:03:03

no, the Clojure runner runs one program, so if you want to start multiple you need to wrap them in something else


@U064X3EF3 Thank you for the quick answer!


Could you call the -main function directly? I guess the main function might be private, but there are ways around that.

Alex Miller (Clojure team)13:03:35

the -main function can't be private (if you want Java to be able to call it)


I can call main functions in a script.


@doglooksgood More and more libraries intended for use with the CLI are getting functions that you can call via -X these days, and those are also more amenable to calling directly from Clojure code, making it easier to write a short Clojure script that calls those functions one after the other. I wouldn't be surprised if we adopted a standardized approach for such pipelines of functions fairly soon...


I'm running with the latest clojure CLI and I've had several occasions now that there's something weird with gitlibs.

borkdude@MBP2019 ~/Dropbox/dev/clojure/babashka/babashka.curl (master*) $ clojure -M:test
Execution error (FileNotFoundException) at clojure.main/main (
Could not locate cognitect/test_runner__init.class, cognitect/test_runner.clj or cognitect/test_runner.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.

Full report at:
borkdude@MBP2019 ~/Dropbox/dev/clojure/babashka/babashka.curl (master*) $ ls -la  ~/.gitlibs/libs/cognitect-labs/test-runner
total 0
drwxr-xr-x  4 borkdude  staff  128 Mar  8 20:14 .
drwxr-xr-x  3 borkdude  staff   96 Mar  8 10:48 ..
drwxr-xr-x  4 borkdude  staff  128 Mar  8 20:14 b6b3193fcc42659d7e46ecd1884a228993441182
drwxr-xr-x  8 borkdude  staff  256 Mar  8 10:48 cb96e80f6f3d3b307c59cbeb49bb0dcb3a2a780b
borkdude@MBP2019 ~/Dropbox/dev/clojure/babashka/babashka.curl (master*) $ ls -la  ~/.gitlibs/libs/cognitect-labs/test-runner/b6b3193fcc42659d7e46ecd1884a228993441182
total 16
drwxr-xr-x  4 borkdude  staff   128 Mar  8 20:14 .
drwxr-xr-x  4 borkdude  staff   128 Mar  8 20:14 ..
-rw-r--r--  1 borkdude  staff   368 Mar  8 20:14 deps.edn
-rw-r--r--  1 borkdude  staff  3491 Mar  8 20:14


moving ~/.gitlibs aside fixes it once again

Alex Miller (Clojure team)19:03:26

so it's a partial checkout?


seems like it yes

Alex Miller (Clojure team)19:03:24

can you share the deps.edn you're using?



{:aliases {:json {:extra-deps {cheshire/cheshire {:mvn/version "5.10.0"}}}
           :test {:extra-paths ["test"]
                  :extra-deps {cheshire./cheshire {:mvn/version "5.10.0"}
                               {:git/url ""
                                :sha "b6b3193fcc42659d7e46ecd1884a228993441182"}}
                  :main-opts ["-m" "cognitect.test-runner"]}}}


(oh I see a typo in the cheshire name, but that wasn't the partial checkout)

Alex Miller (Clojure team)19:03:05

so just the one git lib


it is a gitlib of which I have two different checkouts as you can see

Alex Miller (Clojure team)19:03:55

I assume you didn't like ctrl-c a previous test run


I can't rule that out necessarily


don't remember


maybe a shutdown hook should do some clean up if that is the case?

Alex Miller (Clojure team)19:03:59

what clean up could it do?


I ran into a similar issue today, the symptom was it couldn’t find a namespace. I removed offending folder from ~/.gitlibs but it would only refetch it after running clojure with -Sforce

Alex Miller (Clojure team)19:03:28

I think it's probably better to think about it from perspective of only making it visible when it's done

👍 3
Alex Miller (Clojure team)19:03:12

git itself is using some locking protocols so there is some benefits from cloning into the same dir so I will need to look at this more closely

Alex Miller (Clojure team)19:03:29

(cloning re git dir, not checking out re working trees)


yes, my problem was also fixed using -Sforce


I meant cleaning like removing the entire folder if the checking out was interrupted


maybe some atomic move like construct could also work

Alex Miller (Clojure team)19:03:00

same as corrupted maven downloads