Mismatch between loaded code and actual code

I’m having a problem with a library dependency that does not seem to want to update, and I can’t figure out what is going on.

I’m using clojure.core.memoize, and recently upgraded to 0.7.1. There was a specific bug that was fixed in 0.7.0, so I assumed the bug would be fix with the upgrade. However, the bug is still there.

The weird thing is that the code loaded into the repl seems to be different than the code on disk. For example, if I do (meta #'clojure.core.memoize/fifo), I get :line 242.

But, when I go to definition in cider, the fifo function seems to be on line 292.

This is really weird, because when I look at the history of the memoize library, I can see that the fifo function used to be on line 242, back in version 0.5.9:

What I am assuming this means is that the wrong version of clojure.core.memoize is loaded into memory from somewhere, but I can’t figure out where. I’ve tried deleting my ~/.m2 folder but that didn’t help.

When I run clj -Spath | sed -e 's/:/\'$'\n/g' | grep memoize, all I get is the reference to version 0.7.1:

Same with clj -Stree -Sverbose | grep memoize :
org.clojure/core.memoize 0.7.1

When I deleted the ~/.m2 dir, and re-ran the clj tool, it only showed the 0.7.1 version of memoize being installed:
Downloading: org/clojure/core.memoize/0.7.1/core.memoize-0.7.1.pom from https://repo1.maven.org/maven2/

And, running (require '[clojure.java.classpath :as cp]) (cp/classpath) shows:
#object[java.io.File "0x2f910320" "/home/matthys/.m2/repository/org/clojure/core.memoize/0.7.1/core.memoize-0.7.1.jar"]

Works normally for me:

$ clj -Sdeps '{:deps {org.clojure/core.memoize {:mvn/version "0.7.1"}}}' -e "(require 'clojure.core.memoize)" -e "(:line (meta #'clojure.core.memoize/fifo))"

Can you post your deps.edn?

Thanks for taking the time to look at this.

I’ve spent quite a bit of time on this today, but just figured it out (or at least I think this is what happened).

There was a library (actually 2 libraries) in my dependencies that had an AOT-compiled jar. This jar contained an older version of clojure.core.cache and clojure.core.memoize.

And, it seems that AOT-compiling messes with library dependencies.

Because of this, cider thought I was using the right version of the library, but in actual fact the compiled version of these libraries from the other library (codax) was used.

Found the jar-explorer tool useful for searching through the jar files in my ~/.m2 directory to uncover this information.