Fork me on GitHub
#tools-deps
<
2021-03-08
>
tianshu13:03:22

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

tianshu14:03:14

@U064X3EF3 Thank you for the quick answer!

teodorlu13:03:24

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)

tianshu14:03:18

I can call main functions in a script.

seancorfield16:03:31

@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...

borkdude19:03:55

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

borkdude19:03:45

moving ~/.gitlibs aside fixes it once again

Alex Miller (Clojure team)19:03:26

so it's a partial checkout?

borkdude19:03:43

seems like it yes

Alex Miller (Clojure team)19:03:24

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

borkdude19:03:38

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 ""
                                :sha "b6b3193fcc42659d7e46ecd1884a228993441182"}}
                  :main-opts ["-m" "cognitect.test-runner"]}}}

borkdude19:03:58

(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

borkdude19:03:08

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

borkdude19:03:20

I can't rule that out necessarily

borkdude19:03:30

don't remember

borkdude19:03:58

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?

mkvlr19:03:53

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)

borkdude19:03:48

yes, my problem was also fixed using -Sforce

borkdude19:03:19

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

borkdude19:03:41

maybe some atomic move like construct could also work

Alex Miller (Clojure team)19:03:00

same as corrupted maven downloads