Fork me on GitHub

how do you add dependencies to a running repl?


or is it possible to tell lein to use all the jars in .m2 as dependencies ?


@i Boot lets you add dependencies to a running REPL. CLI/`deps.edn` allows that as well, if you use the add-lib branch of tools.deps.


I'm not sure if you can do it out of the box with Leiningen...

Benny kach05:07:02

Hi guys, there is a library or home-made fn that i can merge n collections by ratio? I mean if i have [1 2 3] and [a b] [z x y] and ratios {:first-coll 1 :second-coll 2 :third-coll 3} so the result should look like (or something similar to) [z x y a b 1 2 3]


@bennyk, I can't tell from that example what you need. What do the ratio values mean? What does it mean that :first-coll is 1 and :second-coll is 2? I'm looking for a pattern in the result and my brain is too tired 😅

Benny kach06:07:51

haha yea sorry for the bad explanation. The function should get N collection and N ratios. It construct 1 new collection. To describe better here is an example: given collection-a: [1 2 3] and collection-b: [a b] and collection-c: [z x y] as input collections, a number Q and {:first-coll 1 :second-coll 2 :third-coll 3} The result collection will contain all the items from the given collections, but ordered like this: construct first Q elements by taking 3 elements from the third collection, 2 from second collection and 1 from third collection. Then construct the next Q items. If for example all the items were already taken from the 2 first collections (collection-a and collection-b) it will just add the items that left from the third collection-c. The end result will look like: [ z x y a b 1 2 3 ]

Benny kach06:07:16

For [1 2 3] and [a b] [z x y w u v] and ratios {:first-coll 1 :second-coll 2 :third-coll 3} => [ z x y a b 1 w u v 2 3 ]


Hello& I'm playing with Ring and trying to send some edn structures between front and back and the opposite way. I believed in Rich's isomorphysm, but all edn<->json converters/middlewares I tried made me disappointed - i.e. on

{1 1,
 "2" "2",
 :a :a,
 [1 "2" :a] [1 "2" :a],
 {1 1, "2" "2", :a :a, [1 "2" :a] [1 "2" :a]}
 {1 1, "2" "2", :a :a, [1 "2" :a] [1 "2" :a]}}
in body on back side I got
  "1": 1,
  "2": "2",
  "a": "a",
  "[1 \"2\" :a]": [
  "{1 1, \"2\" \"2\", :a :a, [1 \"2\" :a] [1 \"2\" :a]}": {
    "1": 1,
    "2": "2",
    "a": "a",
    "[1 \"2\" :a]": [
on front side - it stringifyes all keywords and all key types! Can a achieve a real 1-to1 convertation anyway? I know, that json have not keywords, but I it can be a convention that any string starts with : have to convert to keyword


I do not have much experience with using it myself, but have you tried Transit?


Ok, thanks, I'l see.


@ivana have you seen transit?


@vlaaad not yet, thanks, I'l see it


it's a data format that works over json, but serializes all clojure data structures preserving their types


Sounds promising, I was ready to write my own custom bicycle, but it seems that there is a reason to look at it first 🙂


For testing needs it was easier for me to make some quick and dirty encoder/decoder for transition edn thru json 🙂

(defn encode-edn [x]
    (keyword? x) (str x)
    (map? x) {"map" (map encode-edn x)}
    (coll? x) (mapv encode-edn x)
    :else x))

(defn decode-edn [x]
    (string? x) (if (str/starts-with? x ":") (keyword (subs x 1)) x)
    (map? x) (->> (get x "map") decode-edn (into {}))
    (coll? x) (mapv decode-edn x)
    :else x))


why not just pr-str/`clojure.edn/read-string`?

👍 8

Mmm, let me test it


when making a post from clj-http I am getting an Unhandled unable to find valid certification path to requested target any suggestions of where to start?

Michael Griffiths13:07:28

I’ve debugged this in the past with the JVM option

Michael Griffiths13:07:26

In my case I needed to add the relevant certificates to the JDK Truststore using keytool


Yeah, most likely the server isn't using a trusted certificate. Check with browser or openssl if that's the case. If they say the certificate is valid they might be a mismatch between what Java considers a valid certificate and what browser/OS considers a valid certificate. You may need to import that specific certificate into the java keystore as cichli suggested. In some cases, there might be problems with intermediate certificates.


curl works to the same thing.


@vlaaad thanks, it works nice and I think faster, than construction of temp clojure structures. And I do not need json (with its limitations) anywhere. Seems, that only 2 special points - this string can be readed only with cljs clients (it is not a common json api), and it can not be structured in browser developer tools


Anyone here have much experience with integrant? I posted a q on #integrant but not sure if the channel is in the view of many users.


@bennyk, this is a pretty specialized use-case, so there's no library fn. I'd take the approach of taking each collection, and partition-all by its respective "ratio". (partition-all 3 [1 2 3 4 5 6]) yields ((1 2 3) (4 5 6)). You can then recursively concat the elements of the partitioned collections together.


currently using inside the code to curl it all up, which seems like quite an anti-pattern (and not very production friendly), but resolving cert issues in clojure is definitely testing my knowledge.


@macrobartfast there's a shell command to add a trusted cert for a jvm, that's probably what you want here


keytool -import ... perhaps


thanks! I'll take a look.


in this case it's someone else's server, so don't know if that will help...


also, depending on OS, there's utilities to keep the jvm certs up to date via the package manager


and since curl seems to work, I'm guessing they have things right... but my knowledge of cert stuff is pretty weak.


@macrobartfast the import works with any cert - the example is your own self-signed cert, but the same import works in any case where you know a specific cert should be trusted but it doesn't have a global root


it could be you need to make your OS update java's certs


ah ok... so I would find out what the cert is from the vendor.


lol... I'm really tipping my hand here.


even curl can get you the cert to add (or openssl) iirc


> connects to the desired website and pipes the certificate in PEM format on to another openssl command that reads and parses the details


just got the conj email, exciting!


Where’s the location this year? I haven’t gotten one yet


Durham, North Carolina


Thanks Andy


I need a macro where I use another macro inside. Namely I need a macro that takes a params map and a body, and does with-redefs on some function based on params then run body inside, but I’m struggling with all those splicing/unsplicing rules. Can someone show me a similar example please.


I don't have a specific example, but the main things that helped me with this sort of thing were: 1) understanding that splicing/ quoting etc. are not macro features, they are list construction features 2) the goal of a macro is to construct the code you want compiled as a list - whether your list happens to contain a macro invocation vs. a function call shouldn't change things much


So I need something like this:

(defmacro with-all-redefs
    [{:keys [agreement-map
             certificate-map] & body]
  `(let [doc-pkgs (list agreement-map certificate-map)]
    (with-redefs [db/get-project (constantly doc-pkgs)]


doc-pkgs is invalid as a binding name inside `


right, so how do I make it right?


but for your case here, replacing it with doc-pkgs# suffices


(that's an auto-gensymed local, all uses are guaranteed to use the same symbol)


okay I’ve fixed that, but I think still missing something macroexpand creates strange list of things


maybe that’s what supposed to happen, I dunno. I’m gonna test. Thank you @U051SS2EU


the expansion of ` (especially with ~@) tends to look very weird


oh… my.. I’m so stupid… I was macroexpanding on the macro definition… picard-facepalm


how do I refer to auto-gensymed local from the body?


it's the same


(let [foo# ...] (frob foo#))


oh… okay!


the two uses of foo# are guaranteed too expand to the same auto-generated symbol


now I’m struggling with destructuring… how do you make a macro that take a map and destructure it?


I think the easiest way is to use the normal (non :keys) map destructure


{foo# :foo bar# :bar}


oh, but your :keys destructure is outside the ` block, so it should be fine anyway


why this not working:

(defmacro with-all-redefs
  [params & body]
  `(let [{:keys [foo]} ~@params]
     (prn foo)))
   {:foo "one"})


oh that's not what you had before, you do need the alternative destructure for that


but if it's possible to move the let binding outside the syntax quote block that's even better


okay, let me try that…


damn… macros are really confusing


also that ~@params is surely wrong


cmd)user=> (defmacro with-all-redefs
               [params & body]
               `(let [{foo# :foo} ~params]
                  (prn foo#)))
(ins)user=> (with-all-redefs {:foo "foo"})


… trying


holy shit…. I got it… Thanks man! this is so cool… you saved me hours of work!


Most of the macros I create of are hours of work 🙂


but those sweet sweet minutes of work it saves lol


In a multimethod, is it possible to override the dispatch function and call a specific method? I'd like to create a new method that simply calls one of the other defined methods. (I need to do this because there's a different method that takes priority if I don't. Also, the multimethod is a library function so I can't change it.)


you can reach into the multimethod and pull out the function for a given dispatch value and just invoke it directly


Exactly what I want! What's the syntax for that?


it isn't syntax, you use get-method, pass it the multimethod and the dispatch value to get the function from the multimethod, then pass it whatever arguments


awesome, thanks!


Yep, solved my problem perfectly. Thanks again. I didn't know about get-method, and apparently was using the wrong search terms. 🙂


And in case anyone else ever hits this: if you pass a SQLException to, it'll overflow the stack, because SQLException implements Iterable and returns itself as the first item of the iteration. Can be fixed with: (defmethod from-java java.sql.SQLException [^Object instance] ((get-method from-java :default) instance))


Might be good to put that in a ticket for the library if you are willing. I would be a little bit surprised if the maintainers want to change the lib for that case, but having it documented near the library might be useful.


I'm certainly willing if you think it'd be useful


For all I know, there might be dozens of such weird cases for various Java classes, and trying to collect them all in one place would be a nightmare 🙂


Yeah. I consider this class somewhat ill-behaved. There are getNextException/setNextException methods, but if you access it as an iterator it follows that chain, starting with itself. Nothing that tries to walk the class recursively is going to work. My one-liner ignores the Iterator behavior, but it'll still capture the whole chain of exceptions through the getNextException getter. So that solution is quite specific to this one class.


How does one file a ticket for that project?


The link to do so changed in the past month or so -- let me look for the updated one ...


Going to and clicking the DEV link near the top right takes you to a page with lots of instructions, including a "If you simply need to file a bug, you can do so" link under the "Becoming a Contributor" heading.


That link lets anyone create a bug report, which someone (likely Alex Miller) will decide where it goes.


awesome, thanks

Graham Seyffert23:07:17

Hey folks, I need some more JDK 11 help here

Graham Seyffert23:07:11

I’m getting these kinds of errors on JDK 11, but not JDK 8 -

	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(



Graham Seyffert23:07:45

This error is being thrown when trying to load a function that’s bound in a let


you've compiled stuff on JDK8 that reflects

Graham Seyffert23:07:03

it’s compiled on JDK 8 right now, yes

Graham Seyffert23:07:12

This isn’t reproducible on my local machine though


you're eliding some critical stack traces


there's probably something beneath those traces that will clue you towards what isn't being found

Graham Seyffert23:07:02

I know what isn’t being found, but I can’t figure out why it isn’t being found


is clojure.lang.Reflector in the stack trace?

Graham Seyffert23:07:33

Nope, only jdk internal reflection references

Graham Seyffert23:07:43

I can get the full stack here, but I have to clean up some names before that


@gseyffert the AOT compiled stuff on JDK 8 is probably calling a method on a class that either no longer exists or was renamed on JDK11, or has been made module private in JDK11

Graham Seyffert23:07:34

Actually in this case it’s pulling a function off of a record

Graham Seyffert23:07:09

sorry still cleaning this stack


the function is a protocol method implemented by the record? or a fn stored in a record's field?

Graham Seyffert23:07:07

the latter I believe.

Graham Seyffert23:07:22

accessed via (:a-keyword a-record)


do you get the error accessing the fn on the defrecord, or after accessing when you try to call it?

Graham Seyffert23:07:38

OK here’s the clean stack -


there's an inner function in your_file_name.clj:243, which is being passed to r/fold

Graham Seyffert23:07:27

The flow is basically -

(let [a-fn (:some-kw a-record)
      reduce-fn (bound-fn
                  ([] {})
                  ([m itm]
                   (if (or (nil? a-fn) (a-fn some args)) ;; throws here
  (fold 4 merge reduce-fn a-coll)


possibly an inner inner function


does that inner function use type hints/interop?

Graham Seyffert23:07:44

it does in some cases, but this will throw for record instances that don’t even have :some-kw defined (just nil)


I'd expect that to throw

Graham Seyffert23:07:49

In my code example above it’s more like (if (and a-fn (a-fn some args)) ...)

Graham Seyffert23:07:02

or rather, it’s

Graham Seyffert23:07:28

(if (or (nil? a-fn) (a-fn args)) ...)

Graham Seyffert23:07:12

So we aren’t trying to call nil

Graham Seyffert23:07:38

I attached a remote debugger as well to repro and indeed (nil? a-fn) resolved as true

Graham Seyffert23:07:56

it’s messing me up because we have another similar function that uses the same pattern, except w/out binding a function from a record, and it works just fine


     * Returns a rethrowable exception for this task, if available.
     * To provide accurate stack traces, if the exception was not
     * thrown by the current thread, we try to create a new exception
     * of the same type as the one thrown, but with the recorded
     * exception as its cause. If there is no such constructor, we
     * instead try to use a no-arg constructor, followed by initCause,
     * to the same effect. If none of these apply, or any fail due to
     * other exceptions, we return the recorded exception, which is
     * still correct, although it may contain a misleading stack
     * trace.
     * @return the exception, or null if none


^^^ at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(


at java.base/java.lang.reflect.Constructor.newInstance(
    at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(
    at java.base/java.util.concurrent.ForkJoinTask.reportException(
    at java.base/java.util.concurrent.ForkJoinTask.join(
    at java.base/java.util.concurrent.ForkJoinPool.invoke(
    at clojure.core.reducers$fjinvoke.invokeStatic(reducers.clj:30)
    at clojure.core.reducers$foldvec.invokeStatic(reducers.clj:306)
notice you're in a sad path already


seems like your task failed before this


and FJ is trying to clean up



Graham Seyffert23:07:21

I hear you, but it’s also the case that some instances this works fine, and on other instances it doesn’t

Graham Seyffert23:07:33

Restarting helps, but then over time the errors reappear


"some instances this works fine" -- which instance do you mean?


machine, object instance, execution run?

Graham Seyffert23:07:22

virtual machine, same host

Graham Seyffert23:07:52

So 2 JVMs running on the same host, one will throw this error and the other won’t

Graham Seyffert23:07:02

And once it starts throwing, it doesn’t stop


the class it can't find is one of yours (clojure)?


do you have an accessible REPL on the problematic machine?


was wondering if there is a classloader visibility difference...

Graham Seyffert23:07:42

It does seem to be some issue with the classloader... besides JDK 11, the only correlation I’ve been able to find is just amount of traffic that instance has taken since starting up

Graham Seyffert23:07:34

On this machine I might have a repl. I can look in a few minutes


is the bound-fn necessary?


I wonder if the very first time the offending class gets loaded is within a context in which it cannot initialize


and that just happens to be within the FJPool

Graham Seyffert23:07:17

That’s a sore point haha. I wish it wasn’t but unfortunately it is

Graham Seyffert23:07:34

Much of our stack is ancient and still uses threadlocals (!!!)


I don't mind infrequent thread locals :)


(one of the things the bound-fn might be conveying is a classloader)

Graham Seyffert23:07:09

Hence the usage of bound-fn

Graham Seyffert23:07:20

Hmm that is a thought!


like Compiler/LOADER