Curious behaviour when requiring clojure.tools.cli

33 views
Skip to first unread message

Simon Brooke

unread,
Jun 14, 2021, 8:21:04 AMJun 14
to Clojure

I've discovered a weird behaviour which I don't understand and can't seem to fix - it's probably some obvious mistake of my own.

Brief background, I'm trying to integrate cloverage with codox, so that I can show test coverage reports on my documentation pages. Both of these are established, solid, well written packages by respected members of the community.

Cloverage (1.3.0-SNAPSHOT) depends on clojure.tools.cli version 0.4.2. When you start a repl within the cloverage/cloverage directory and attempt to use clojure.tools.cli, no problem:

    cloverage.coverage=> (use 'clojure.tools.cli)
    nil

Codox 0.10.7 does not depend on clojure.tools.cli, but my mildly modified version of codox does depend on cloverage 1.3.0-SNAPSHOT (that is literally the only change to the codox project.clj). When you start a repl within the codox/codox directory, and attempt to use clojure.tools.cli, you get:

    user=> (use 'clojure.tools.cli)
    CompilerException java.lang.RuntimeException: No such var: s/starts-with?, compiling:(clojure/tools/cli.cljc:97:8) 

OK, so, it's picking up clojure.tools.cli at all presumably via the dependency on cloverage, which is good. but clojure.tools.cli requires clojure.string as `s`, see
so you would have thought this would all work fine.

So what happens if I require clojure.string as `s` in the repl? Well, I get a different error:

    user=> (require '[clojure.string :as s])
    nil
    user=> (use 'clojure.tools.cli)
    CompilerException java.lang.Exception: namespace 'clojure.tools.cli' not found, compiling:(/tmp/form-init1843820122884430414.clj:1:1) 

So, can anyone explain what is going on here, and how I fix it? it matters to me, because it prevents my code from compiling:

    user=> (use 'codox.cloverage-integration.runner :reload)
    CompilerException java.lang.RuntimeException: No such var: s/starts-with?, compiling:(clojure/tools/cli.cljc:97:8)

In case anyone's interested, my current diff with respect to weavejester's current codox is here: https://github.com/simon-brooke/codox/commit/ef4ba70659c768f1aab4bfbf32efdaa48e9c43a8

Thanks in advance for any help or thoughts!


Thomas Heller

unread,
Jun 14, 2021, 3:02:13 PMJun 14
to Clojure
clojure.string/starts-with? was added in Clojure 1.8.0, I see 1.7.0 in the project.clj?


What exactly else is going on I don't know but it all starts from the wrong Clojure version.

HTH

Simon Brooke

unread,
Jun 14, 2021, 5:00:17 PMJun 14
to Clojure
Thank you, that was the right answer (and I would not have thought of it myself). Codox was on Clojure 1.7.0, but it was also on org.clojure/tools.namespace 0.2.11. Cloverage is on 1.10.1 and 1.0.0 respectively, and if I bring the Codox versions into line with the Cloverage versions, it all works.

So I think I can get this working for me. I'm less confident of getting upstream to accept a pull request for such a major change.
Reply all
Reply to author
Forward
0 new messages