This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-20
Channels
- # babashka (56)
- # beginners (151)
- # calva (3)
- # cider (31)
- # clj-kondo (17)
- # cljs-dev (5)
- # clojure (26)
- # clojure-australia (21)
- # clojure-dev (7)
- # clojure-europe (23)
- # clojure-nl (5)
- # clojure-spec (54)
- # clojure-uk (11)
- # clojuredesign-podcast (8)
- # clojurescript (77)
- # community-development (10)
- # core-typed (1)
- # cursive (3)
- # datomic (7)
- # docker (67)
- # emacs (10)
- # expound (6)
- # figwheel-main (3)
- # graalvm (67)
- # helix (10)
- # java (13)
- # jobs (6)
- # kaocha (4)
- # leiningen (15)
- # malli (2)
- # meander (31)
- # off-topic (40)
- # pedestal (9)
- # rdf (7)
- # reagent (5)
- # reitit (9)
- # remote-jobs (5)
- # shadow-cljs (94)
- # sql (7)
- # testing (12)
- # tools-deps (75)
- # vim (13)
Could anyone give me a hand with this error?
Var clojure.test.check.generators/simple-type-printable does not exist, clojure.test.check.generators never required
happens every time I call `(spec/explain ::my-spec my-val)` in ClojureScript. I don't have instrumentation turned on.
I've followed the advice at https://stackoverflow.com/questions/57877004/how-to-fix-clojure-test-check-generators-never-required-when-exercising-a-func and added `org.clojure/test.check` to my `deps.edn` dependencies, but it hasn't fixed the problem.
but it surprises me that s/explain needs test.check, that should not be the case I think
@neil.hansen.31 which version of CLJS are you using?
borkdude@MBP2019 /tmp $ clj -A:test -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.597"}}}' -m cljs.main -re node
WARNING: When invoking clojure.main, use -M
ClojureScript 1.10.597
cljs.user=> (require '[clojure.spec.alpha :as s])
nil
cljs.user=> (s/def ::foo int?)
:cljs.user/foo
cljs.user=> (s/explain ::foo 1)
Success!
nil
@borkdude I'm on 1.10.773. I'm trying it on an empty REPL now and it's working as your example is... I guess something is going on in my Figwheel build that I'll have to figure out...
Yes, it's definitely something to do with fspec. It also seems to act strange in this case:
(spec/fdef foo
:args (spec/fspec :args (spec/cat)))
When I instrument these functions:
(defn foo []
nil)
(defn bar []
nil)
I get a "spec failed... should satisfy ifn?" expound error with this:
(foo bar)
@neil.hansen.31 Why are you using fspec
here?
I made an assumption from the https://clojure.org/guides/spec#_higher_order_functions that fspec
would work for :args
, but it seems like it's only for :ret
. I was hoping that spec could check that the arguments to my function would receive only certain arguments.
Oh, also my example for foo was wrong up above, sorry, it should have been something like:
(defn foo [f]
(f))
(defn bar []
nil)
(foo bar)
Then your spec may have been correct, and the error message makes sense. Foo wasn't passed an IFn
I think it should be something like:
(spec/fdef foo
:args (spec/cat :f (spec/fspec :args (spec/cat))))
In Clojure:
user=> (require '[clojure.spec.alpha :as spec])
nil
user=> (spec/fdef foo
#_=> :args (spec/cat :f (spec/fspec :args (spec/cat))))
user/foo
user=> (defn foo [f] (f))
#'user/foo
user=> (stest/instrument 'user/foo)
[user/foo]
user=> (foo identity)
Execution error (FileNotFoundException) at user/eval35926 (form-init3141792093562271177.clj:1).
Could not locate clojure/test/check/generators__init.class, clojure/test/check/generators.clj or clojure/test/check/generators.cljc on classpath.
user=> (foo (fn []))
Execution error (FileNotFoundException) at user/eval35926 (form-init3141792093562271177.clj:1).
Could not locate clojure/test/check/generators__init.class, clojure/test/check/generators.clj or clojure/test/check/generators.cljc on classpath.
Oh my goodness, you're right, thank you so much. The :args
always have to bee a tuple don't they.
Got it. Funny enough, when I instrument that spec you gave me, I get the error again:
Var clojure.test.check.generators/simple-type-printable does not exist, clojure.test.check.generators never required
yeah, it seems fspec somehow needs test.check. I've never used fspec personally. It seems to be the same in CLJ:
user=> (foo (fn []))
Execution error (FileNotFoundException) at user/eval35926 (form-init3141792093562271177.clj:1).
Could not locate clojure/test/check/generators__init.class, clojure/test/check/generators.clj or clojure/test/check/generators.cljc on classpath.
So not sure what's happening... For now I'll take your advice and check for ifn?
in my :args
instead.
Hmm it looks like this is a Figwheel-specific problem. I've made a very minimal test file:
(ns cards.core
(:require
[clojure.test.check :as check]
[clojure.spec.test.alpha :as stest]
[clojure.spec.alpha :as spec]))
(spec/fdef foo
:args (spec/cat :f (spec/fspec
:args (spec/cat))))
(defn foo [f] f)
(defn bar [] nil)
(stest/instrument)
(foo bar)
Evaluating (foo bar)
with clj -m figwheel.main
returns #object[Error Error: Var clojure.test.check.properties/for-all* does not exist, clojure.test.check.properties never required]
Slightly different error from my original one, but I'd think the problem comes from the same place?
You can try to compile this without figwheel and see if that's it. And then file a bug report with figwheel
https://github.com/bhauman/figwheel-main/issues/272 for all those who are lost in the future.
Have you also tried to compile this without Figwheel, but using regular CLJS? That's not clear from this issue
I'll do that, I'll close the figwheel issue when someone advises. Thanks again for everything.
I think it would be good to close the figwheel issue and comment that it's not an issue with figwheel, else you might be wasting the maintainer's time.