Question

This is really important, and I am totally stumped and on a deadline. Help is greatly appreciated.

I have a Clojure project called red-black, which in particular contains a file called interval_tree.clj

I have been compiling this project with lein uberjar and then using the resulting jar in other projects by installing it in a local maven repository.

mvn install:install-file  \   
    -Dfile=../red-black/target/red-black-0.1.0.jar  \  
    -DgroupId=self   \
    -DartifactId=red-black  \
    -Dversion=0.1.0  \
    -Dpackaging=jar  \
    -DgeneratePom=true  \
    -DcreateChecksum=true  \
    -DlocalRepositoryPath=local_mvn_repo

The crazy thing is, I added a new function, compiled my jar and reinstalled it in the local maven repository of another project, and now java cant find my new function

user=> (red-black.interval-tree/tree-to-flat-list )
CompilerException java.lang.RuntimeException: No such var: red-black.interval-tree/tree-to-flat-list, compiling (NO_SOURCE_PATH:1:1)

However this function is in red-black.interval-tree.clj! I even went into my local_mvn_repo, unzipped the jar, and looked at the interval_tree.clj source. The function is in there!

Whats even more strange is that the other function from that library are accessible. For example, in my second project with the local mvn repo:

user=> (use 'red-black.interval-tree)
nil

Now a little tab tab magic:

user=> (red-black.interval-tree/
red-black.interval-tree/add-to-result        red-black.interval-tree/black                red-black.interval-tree/check-max-interval
red-black.interval-tree/get-color            red-black.interval-tree/get-hash             red-black.interval-tree/get-interval
red-black.interval-tree/get-key              red-black.interval-tree/get-left             red-black.interval-tree/get-max
red-black.interval-tree/get-parent           red-black.interval-tree/get-right            red-black.interval-tree/get-root
red-black.interval-tree/get-sentinel         red-black.interval-tree/get-value            red-black.interval-tree/has?
red-black.interval-tree/health-check         red-black.interval-tree/high                 red-black.interval-tree/insert
red-black.interval-tree/insert-fixup         red-black.interval-tree/left-rotate          red-black.interval-tree/low
red-black.interval-tree/max-of-three         red-black.interval-tree/new                  red-black.interval-tree/node
red-black.interval-tree/point-lookup         red-black.interval-tree/pretty-print         red-black.interval-tree/recursive-max
red-black.interval-tree/red                  red-black.interval-tree/right-rotate         red-black.interval-tree/set-color
red-black.interval-tree/set-interval         red-black.interval-tree/set-key              red-black.interval-tree/set-left
red-black.interval-tree/set-max              red-black.interval-tree/set-parent           red-black.interval-tree/set-right
red-black.interval-tree/set-root             red-black.interval-tree/set-value            red-black.interval-tree/update-max
user=> (red-black.interval-tree/

But as you can see the funstion tree-to-flat-list is missing. When I go back into my red-black project and launch the repl, I can invoke the project just find. Help! As of 5 hours ago I was creating new methods in my red-black project, compiling my uberjar and installing it in my other project via local maven install, and new methods were being picked up just fine. Something appears to be very wrong, please advise!

Update:

A self contained example of this issue is in this tarball:

http://gorillamatrix.com/files/foo.tar.gz

Go into foo-two and lein repl. Try to load foo-two.core, you should see this:

user=> (use 'foo-two.core)
CompilerException java.lang.RuntimeException: No such var: foo-one.core/bar, compiling:(foo_two/core.clj:6:2)

However foo-one.core/bar is certainly defined!

Was it helpful?

Solution

lein doesn't update the already fetched (from local_mvn_repo) .jar into .m2/repositories if it has the same version (it seems), so you're still using the first one that it fetched (it will always use the one that's in .m2 not the one in local_mvn_repo) So you can either increase version and reinstall (make sure u also update version in your project.clj of the project that uses it) or (if still using the same version)just delete it from /.m2/repositories so that lein can fetch it again(from local_mvn_repo)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top