Fork me on GitHub
#leiningen
<
2017-09-17
>
jsa-aerial20:09:13

OK, I think I've seen something about this issue before - probably in #clojure channel, but this seems more appropriate. I didn't pay much attention before, because I had never hit this issue. Anyway, I have lib that I created (does use both clj and cljs). Works fine if I am just running in development - no jars just direct from source. OK, so I then create a jar for it and deploy (locally for now - that works fine for me on all sorts of other stuff). If I include this as a dependency in some new project, it seems to bungle the classpath so that unless something is in the lib's jar or directly in the new projects project.clj it is not visible. I tried with and without :aot, with lein jar and lein uberjar (with and without :aot)

jsa-aerial20:09:52

Ran out of ideas and thought that this sort of thing I've seen reported before. Any clues much appreciated

noisesmith20:09:11

uberjar should not be used for libraries; there are edge cases for using aot with libraries but it is tricky and probably not worth the trouble

noisesmith20:09:22

how are you adding the dependency to the other project?

jsa-aerial20:09:26

@noisesmith Thanks for info. Adding the dependency in new project's project.clj in its dependency vector with this: [vgl "0.1.0"]

noisesmith20:09:49

can you run lein deps :tree in the second project (the one with that dep) - you should see various libraries under that one in the tree

jsa-aerial20:09:41

OK, let me do that - I did run that before, but was only looking at conflicts

jsa-aerial20:09:11

OK, just ran it and - nothing under it. Just the single [vgl "0.1.0"] and nothing else.:thinking_face:

noisesmith20:09:05

and it has deps, that the parent project doesn't pull in, that as a result are not available?

noisesmith20:09:03

what does the pom.xml that lein install generates look like? this is the document that specifies deps, it gets put beside your jar under ~/.m2/repository/

jsa-aerial20:09:17

yes, that definitely seems to be the case. Must be something broken with it's (lib) project.clj??

jsa-aerial20:09:40

let me check that

noisesmith20:09:43

if the pom.xml doesn't have your deps specified in it, that would indicate a problem

jsa-aerial20:09:09

I'm guessing it doesn't, but let me see

jsa-aerial20:09:39

wow, there is no pom there: `dir ~/.m2/repository/vgl/vgl/0.1.0/ total 8768 -rw-rw-r-- 1 jsa jsa 149 Sep 17 13:02 _maven.repositories -rw-rw-r-- 1 jsa jsa 8970247 Sep 17 13:02 vgl-0.1.0.jar`

jsa-aerial20:09:48

the local deploy has nothing either...

noisesmith20:09:05

oh, it is actually vgl-0.1.0.pom that you would see

jsa-aerial20:09:32

Yeah, I don't see that anywhere...

noisesmith20:09:32

what about if you run lein pom?

noisesmith20:09:48

I mean, lein install should be making and renaming that pom for you...

noisesmith20:09:55

just trying to figure out where this is breaking down

jsa-aerial20:09:17

OK, never done that before - should I run that in lib or new project or??

noisesmith20:09:50

in the lib - lein pom generates the pom.xml file that eventually becomes lib.pom and other apps use that file to figure out what your deps are

jsa-aerial20:09:34

makes sense - running now

jsa-aerial20:09:09

it generated it and there is a lot of stuff in there

noisesmith20:09:09

weird, running lein install should have put that in the cache with your jar (which is clearly there...)

jsa-aerial21:09:02

wait a minute, I didn't run lein install, just lein deploy to lcldir in new proj director and then just lein deps. it did say it was fetching from lcl but maybe I need to run lein install after lein deploy?

jsa-aerial21:09:50

Also, I do see the pom in the jar

noisesmith21:09:06

right but dep management doesn't open the jar

noisesmith21:09:54

I don't know how your local repo works, I have literally never needed one, lein install does everything I've needed

jsa-aerial21:09:36

I think I've hit the current limit of my deps mgt knowledge.

noisesmith21:09:03

@jsa-aerial see what happens if you remove the project from your local repo (or bump version and ask for new version) and run lein install from your lib

noisesmith21:09:17

that should just do the right thing with no complications in my experience

jsa-aerial21:09:17

Here's what I've used : lein deploy lclrepo vgl 0.1.0 /path/to/jar/vgl-0.1.0.jar

noisesmith21:09:32

do what I suggested, it's simpler

noisesmith21:09:42

you don't need a local repo for this

jsa-aerial21:09:50

Sounds good - I do this in the library dir?

jsa-aerial21:09:33

dang - should I have removed the current m2 version?

noisesmith21:09:11

no, running install overwrites the m2 cache

jsa-aerial21:09:55

OK, I've got my self in a tangle removing everything and cleaning. So, the steps are simply 1) lein jar and then 2) lein install?

noisesmith21:09:07

no, there's only one step lein install

noisesmith21:09:11

then you go start your other project

noisesmith21:09:35

it's really a lot simpler than people expect and I think this leads to problems

noisesmith21:09:56

because people expect installing a local dep to be weird and complicated, so they go find weird complicated solutions haha

jsa-aerial21:09:29

pom and jar are now there in the .m2 .... area trying new project

noisesmith21:09:18

the one gotcha for using any local cache is that if you are deploying and expect others to be able to resolve your dep, you need to remember to push up a new version of your artifact to the shared repo when pushing code that uses it (it's easy to forget and say "it works for me" because you did a local install, which is a pain for the rest of the team)

jsa-aerial21:09:31

I see. I think it is working - better, for some value of 'better'.

jsa-aerial21:09:27

I think what is now messed up is that in attempting to 'fix' this before, I peppered the dependencies with all sorts of exclusions and one of those seems to have been excluded altogether...

noisesmith21:09:40

oh, that sounds easy to fix though

jsa-aerial21:09:50

@noisesmith Many Many Thanks for helping with this!!