[Bug]: Datahike 0.6.1532+ appears to be enabling spec instrumentation
psagers opened this issue · comments
What version of Datahike are you using?
0.6.1537
What version of Java are you using?
"17.0.6" 2023-01-17
What operating system are you using?
Arch
What database EDN configuration are you using?
None
Describe the bug
When Datahike 0.6.1532 or later is in the project dependencies, clojure.spec instrumentation gets turned on somewhere. This did not occur with 0.6.1531.
What is the expected behaviour?
No instrumentation by default.
How can the behaviour be reproduced?
Here's a trivial repro:
deps.edn:
{:paths ["src"]
:deps {cli-matic/cli-matic {:mvn/version "0.5.4"}
io.replikativ/datahike {:mvn/version "0.6.1537"}}}
src/main.clj:
(ns main
(:require
[cli-matic.core :refer [run-cmd]]
[clojure.spec.test.alpha :as stest]))
(defn print-help
[_]
"This program does nothing.")
(def CLI-CONFIG
{:command "main"
:description "Do a thing."
:subcommands [{:command "help"
:runs print-help}]})
(defn -main
[& args]
;; (stest/unstrument)
(run-cmd args CLI-CONFIG))
$ clojure -Srepro -M -m main
Execution error - invalid arguments to cli-matic.utils-v2/cfg-v2 at (test.cljc:30).
{:command "main", :description "Do a thing.", :subcommands [{:command "help", :runs #object[main$print_help 0x110620d "main$print_help@110620d"]}]} - failed: (contains? % :opts) at: [:cfg :v2 :branch] spec: :cli-matic.specs/any-subcommand
{:command "main", :description "Do a thing.", :subcommands [{:command "help", :runs #object[main$print_help 0x110620d "main$print_help@110620d"]}]} - failed: (contains? % :opts) at: [:cfg :v2 :leaf] spec: :cli-matic.specs/any-subcommand
{:command "main", :description "Do a thing.", :subcommands [{:command "help", :runs #object[main$print_help 0x110620d "main$print_help@110620d"]}]} - failed: (contains? % :app) at: [:cfg :v1] spec: :cli-matic.specs/climatic-cfg-classic
{:command "main", :description "Do a thing.", :subcommands [{:command "help", :runs #object[main$print_help 0x110620d "main$print_help@110620d"]}]} - failed: (contains? % :global-opts) at: [:cfg :v1] spec: :cli-matic.specs/climatic-cfg-classic
{:command "main", :description "Do a thing.", :subcommands [{:command "help", :runs #object[main$print_help 0x110620d "main$print_help@110620d"]}]} - failed: (contains? % :commands) at: [:cfg :v1] spec: :cli-matic.specs/climatic-cfg-classic
The spec errors do not appear if you uncomment (stest/unstrument)
in -main
or downgrade to datahike 0.6.1531.
I've used cli-matic for demonstration purposes, but I first observed instrumentation errors from an unrelated library (edn-query-language). As far as I can tell, the behavior is wholly determined by the version of datahike in deps.edn.
Hey @psagers, thanks for reporting. Looks like a weird one. Maybe there is some interaction between the orchestra package that probably slipped into datahike by accident and the other library you are using.
Can you try excluding orchestra/orchestra
from the datahike dependency?
Yeah, that's it. I poked around some more and found that the mere presence of orchestra is causing cli-matic to enable instrumentation. Very bad. The repro case just happened to stumble on a subtle interaction. I'll file a bug over there.
Thanks!
You are welcome.