Fork me on GitHub
#tools-deps
<
2023-10-11
>
Alan Birchenough19:10:48

I have a noob question about preparing libs to be :local/root source dependencies. I have such a lib, but I can't get the dependency to work because no matter what I do, clj still thinks the library has not been prepped. It is a tiny library consisting of one source file plus a couple of Maven deps on Commons IO and Clojure Data CSV. I have run clj -X:deps prep on this library, and that process added the expected required content to deps.edn, to wit: {:paths ["src" "target/classes"] :deps/prep-lib {:alias :build :fn compile :ensure "target/classes"}} I then go to another tiny project that specifies my library as a :local/root dependency and try to start it up, but I always get a classpath error that the lib is not prepped. What am I (probably) missing?

Alex Miller (Clojure team)19:10:45

is there a target/classes in the dir?

Alan Birchenough19:10:14

It was not clear to me how that should be created.

Alex Miller (Clojure team)19:10:34

to translate {:alias :build :fn compile :ensure "target/classes"} into words... if this project does not have "target/classes", run clj -T:build compile (which should put something in target/classes)

Alan Birchenough19:10:11

I would literally run the command in red?

Alex Miller (Clojure team)19:10:31

you don't run it - prep will run it for you when you use it from another project

Alex Miller (Clojure team)19:10:44

I mean, you can run it, and then it should appear prepped

Alan Birchenough19:10:01

Do I run prep while in the other project, as opposed to running it while in the library project dir?

Alex Miller (Clojure team)19:10:29

clj -X:deps prep means "prepare my deps to be on my classpath"

Alan Birchenough19:10:35

When I run the prep command in the other project, it complains that it doesn't know what compile is.

Alex Miller (Clojure team)19:10:14

we may have run out of specific-enough information at this point

Alan Birchenough19:10:29

LOL - I would be happy to provide more specifics.

Alan Birchenough19:10:42

It does, but not as explicitly. It was not clear to me which deps.edn would acquire those new entries and which dir I should be in when I ran the prep command, for instance.

Alan Birchenough19:10:26

Probably because I don't really understand what I am / it is doing.

Alex Miller (Clojure team)19:10:59

that example has: • needs-prep - a local lib that needs prepping. it has the :deps/prep-lib in its deps.edn • cool-lib - a project using needs-prep, includes needs-prep as a :local/root dep. clj -X:deps prep is run here

Alan Birchenough19:10:51

I will give this another try based on that understanding. Thank you.

Alex Miller (Clojure team)19:10:22

I can see why that example does not fully specify, will try to improve it

Alan Birchenough19:10:40

This is the error I get when I run prep in my equivalent of cool-lib: Prepping csvlib/core in /Users/alanbirchenough/clojure/csvlib Execution error (ExceptionInfo) at clojure.tools.deps/qualify-fn (deps.clj:654). Unqualified function can't be resolved: compile

Alan Birchenough19:10:36

@U064X3EF3 Can you please suggest what I should do to diagnose this error, now that I appear to be executing the process correctly? Thanks.

Alan Birchenough19:10:51

I think I know what is causing this.

Alan Birchenough19:10:23

Closing the loop, then I'll shut up: Because I prepped while in my-lib instead of in cool-lib, I had a bogus reference to compile in my deps.edn.

Alan Birchenough21:10:47

Seems to be, thanks.

Alan Birchenough21:10:45

Thank you very much for your assistance with this process.

clojure-spin 1
stathissideris10:10:44

amazing, came to this channel to ask about this exactly, and the thread was right here ❤️ thank you!