Fork me on GitHub
#clj-kondo
<
2023-08-10
>
John Doe05:08:00

beginner question: When I tried to change a var in some library, for example (alter-var-root #'cheshire.parse/*use-bigdecimals?* (constantly true)) clj-kondo complains Unresolved namespace cheshire.parse. Are you missing a require? . Do I actully need to add a require cheshire.parse to suppress the warning, or is this just a false positive warning to ignore?

jumar05:08:53

Yes, in clojure you need to require a namespace before using its vars

👍 2
John Doe06:08:12

If I just create a new empty ns without any require and run the code , it just runs and changes the global var from that library. Is this expected?

delaguardo07:08:42

you can use qualified vars without requiring the namespace but only if the corresponding namespace was loaded (for example requered transitively). but it is always better to be explicit and require in the namespace that uses that var

❤️ 4
John Doe07:08:22

Thanks for the explanation. I do have a http client which has a {:as :json} which requires cheshire transitively I guess. Is there a way to list all namespaces being required transitively so I can verify this case?

John Doe08:08:47

Ahh, thanks again! I can see where it's loaded now. Much appreciated!