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.
Could you call the -main
function directly? I guess the main function might be private, but there are ways around that.
the -main function can't be private (if you want Java to be able to call it)
no, the Clojure runner runs one program, so if you want to start multiple you need to wrap them in something else
@alexmiller Thank you for the quick answer!
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 (main.java:40).
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:
/var/folders/2m/h3cvrr1x4296p315vbk7m32c0000gp/T/clojure-11182883341768341391.edn
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 readme.md
moving ~/.gitlibs
aside fixes it once again
so it's a partial checkout?
seems like it yes
can you share the deps.edn you're using?
sure:
{:aliases {:json {:extra-deps {cheshire/cheshire {:mvn/version "5.10.0"}}}
:test {:extra-paths ["test"]
:extra-deps {cheshire./cheshire {:mvn/version "5.10.0"}
cognitect-labs/test-runner
{:git/url "<https://github.com/cognitect-labs/test-runner>"
:sha "b6b3193fcc42659d7e46ecd1884a228993441182"}}
:main-opts ["-m" "cognitect.test-runner"]}}}
(oh I see a typo in the cheshire name, but that wasn't the partial checkout)
so just the one git lib
yes
it is a gitlib of which I have two different checkouts as you can see
sure
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?
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
I think it's probably better to think about it from perspective of only making it visible when it's done
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
(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
yes, that makes sense
same as corrupted maven downloads