Fork me on GitHub

is there some idiomatic way, other than read-string , of grabbing an artifact version out of a deps.edn file? I need this on the command line from a bash script and I can do the read-string call via a call to clojure with appropriate code snippet. Was perhaps hoping there would be something built in to say tools.deps to accomplish this?

Ben Sless08:01:06

Maybe a tool like #jet or cq?


right, yes, that would work but this is part of a build process checked into a git repo and I was hoping to not have to install additional binaries on the building if possible I'm looking for a clojure solution, clojure deps are ok as they can be auto-downloaded, but would prefer to stay away from system binaries


ok digging into tools.deps...seems there are functions in there that might do this


I have a test which is comparing 2 maps when I run the test I get this result which I don't understand as that looks the same, I have done an external diff and both maps seem to be identical but I still see the test fail with the below diff. anyone got any pointers ?

diff: - nil          
          + nil            


The maps are nested so maps in maps and vectors as key values they also have time and uuid literals like these #time/instant "2019-06-05T08:48:45Z"


If i intentionally change the maps the diff shows the correct keys as different, I have done similar tests before and not encountered this behaviour


Another question about map comparisons! How would you approximately compare two maps based on some epsilon value, e.g.:

(let [m1  {:a    46.042
           :name "Jim"}
      m2  {:a    45.041
           :name "Jim"}
      eps 0.005]
 (approx= m1 m2 eps))
;;=> true
the maps could be arbitrarily nested I suppose I could walk over the map and use something like for numbers and clojure.core/= for other non-collection types but I'm not sure it's the right approach, it feels kinda wrong. How do people usually solve this?

Alex Miller (Clojure team)14:01:12

you could use to pull a list of differences and then compare only those

πŸ’‘ 1
πŸ™ 1

I did actually try that I get back nil nil and the map as the 3rd parameter, which I believe means no differences if the first and second value are both nil


I just went down the route of dissocing keys to find the key but its a key with a vector of maps which only contain strings or integers so nothing esoteric

Alex Miller (Clojure team)14:01:27

sorry, I was actually replying to @pavlos’s question :)


ah no worries, I guess we are looking at similar things

Alex Miller (Clojure team)15:01:30

any chance you have a nil value and programatically constructed symbol with the value nil?

Alex Miller (Clojure team)15:01:25

^^ bad, but possible :)


Fail in t

expected: {:id 6,
           :merchant_id 2,
           :billing_period 2,
           :name "Deactivated Feed",
           :feed_type_id 2}

  actual: {:id 6,          
           :merchant_id 2,
           :billing_period 2,
           :name "Deactivated Feed",
           :feed_type_id 2}
    diff: - nil          
          + nil            
I have drilled into the hashmap to get at this sub map which is failing


just going to start disocing from that I guess until it passes


Fail in t

expected: {}

  actual: {}          
    diff: - nil          
          + nil            
Even more confused now no key values left and it still fails 😞


do you have some sort of testing facility/pretty-printer?


got it different types I wrapped in type fn and all became clear thanks for your duckie πŸ™‚


not sure I understand -- can you elaborate?


so one is a clojure.lang.PersistentArrayMap the other is a postgres instance which happens to display as a hashmap when displaying


what is the class of the Postgres instance?


is there an easy way to load all files in a jar (use case is to not restart repl)?


so I am using a library called toucan which creates a class per table/model


@oliver.marks I think I've sometimes seen that when the values you're comparing are a map and a record


(defrecord Foo [foo])
(deftest foo-test
  (is (= (map->Foo {:foo "foo"}) {:foo "foo"})))


looks like you got a handle on it though πŸ™‚


yeah be nice if the diff could report that kind of difference the amount of lost time trying to nail down the issue :p

Volodymyr Anokhin21:01:36

Hi. I try to instantiate class javax.jms.ServerSessionPool that has no ctor and get

Execution error (ClassCastException) at aq-test.consumer/receive-msg (consumer.clj:11).
class java.lang.Class cannot be cast to class javax.jms.ServerSessionPool (java.lang.Class is in module java.base of loader 'bootstrap'; javax.jms.ServerSessionPool is in unnamed module of loader 'app')
Parts of my code that are related:
(ns aq-test.consumer
  (:import [javax.jms ServerSessionPool]))
(let  consumer-instance [(.createConnectionConsumer connection queue "JMSPriority BETWEEN 3 AND 7", ServerSessionPool, 1000)] ;; <-- Failing here
Any hints how to proceed?


the code is passing a class instead of an instance of the class

Volodymyr Anokhin21:01:16

yup -- and if I change it to (ServerSessionPool.) I get

Syntax error (IllegalArgumentException) compiling new at (/tmp/form-init8842840836338661175.clj:1:215).
No matching ctor found for interface javax.jms.ServerSessionPool

Volodymyr Anokhin21:01:22

This ServerSessionPool thing seems not having any constructors

Volodymyr Anokhin21:01:16

yup -- and if I change it to (ServerSessionPool.) I get

Syntax error (IllegalArgumentException) compiling new at (/tmp/form-init8842840836338661175.clj:1:215).
No matching ctor found for interface javax.jms.ServerSessionPool


don't guess


check out the docs for ServerSessionPool and call the constructor you need


it might not even have a public constructor; might get one from some static factory method somewhere (I don't know)


it's an interface, so it might come from the JMS concrete backend library that you are using


e.g. ActiveMQ or whatever

Volodymyr Anokhin21:01:02

Oh, so additionally the implementation may be needed? I didn't thought of that. Thanks!


no problem. sorry I don't have more specific details

πŸ™Œ 1

Where is the config file for clj so I can put this mess in it? It doesn't make any sense to put it in every project's deps.edn, but I can't find docs about any other config. {:deps {cider/cider-nrepl {:mvn/version "0.27.3"} }}' -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"


put this in .clojure/deps.edn

πŸ‘ 2

  {:extra-deps {nrepl/nrepl {:mvn/version "0.9.0-beta3"}
                cider/cider-nrepl {:mvn/version "0.27.2"}}
   :main-opts ["-m" "nrepl.cmdline"
               "--middleware" "[cider.nrepl/cider-middleware]"]}}}


Who can I bug to get that on this page?


in the reference


But ~/.clojure/deps.edn isn't mentioned there


Under the heading "Operation" you can find this line: User - cross-project configuration (typically tools), usually found atΒ `~/.clojure/deps.edn`


brilliant, thanks!


@U02UHTG2YH5 you are right. I totally sent the wrong link. I glanced quickly before doing a little meeting and it looked like the right thing. Sorry about that


No worries. Just concerned for my eyes for a minute πŸ™‚


You may find this user level configuration interesting, it has lots of examples of aliases for tools, libraries and middleware like Cider

πŸ‘ 1

That is a very useful reference. Thank you!

πŸ‘ 1