tools-deps

cfleming 2023-06-22T03:06:20.770639Z

I’m feeling a bit silly about this, but I can’t figure out the incantation to get a REPL using a tool classpath. Say I would normally do clojure -T:build <something> to run a tool, how do I start a REPL with that classpath?

seancorfield 2023-06-22T03:38:55.489429Z

This made me curious. In theory you can run clojure -Tmy-tool some-fn where some-fn will start a REPL... but the gotcha is that it needs to accept a single hash map argument -- for -X style invocation -- and I couldn't find anything that fit the bill...

cfleming 2023-06-22T03:39:37.583069Z

Does this mean that no-one is using REPLs to develop their builds? It makes me feel better about not doing it myself, but surprises me.

seancorfield 2023-06-22T03:40:08.256189Z

You said "tool" so I assumed you meant -Tmy-tool not -T:some-alias

cfleming 2023-06-22T03:41:00.765839Z

In my case it’s an alias, with a :deps and a :ns-default

seancorfield 2023-06-22T03:41:13.352049Z

clojure -A:the-alias

cfleming 2023-06-22T03:41:24.400719Z

Which is a tool, right? Perhaps I’m not getting the terminology right.

cfleming 2023-06-22T03:41:40.399809Z

But that will also include the project classpath, and not just the tool classpath.

cfleming 2023-06-22T03:42:08.699299Z

i.e. it’s the -T that does the replacing of the project classpath and paths.

seancorfield 2023-06-22T03:42:21.407089Z

Yeah, I start a "build REPL" at work with clj -M:build -i build.clj -r I think

seancorfield 2023-06-22T03:43:49.368649Z

Let me see what's in the script I use for that... I suspect it works well because it's a Polylith project and there are no dependencies unless you specify the :dev alias 🙂

seancorfield 2023-06-22T03:45:06.485719Z

Oh, I only have that on my other machine so I can't check right now.

cfleming 2023-06-22T03:46:04.962239Z

So I just tried that in my project, and I get the project paths, at least (`src` etc, not .)

seancorfield 2023-06-22T03:46:05.699629Z

Mostly when I'm working with my build.clj, I just use -M:build or similar and don't care whether the rest of the project is accessible or not.

cfleming 2023-06-22T03:47:17.307259Z

That seems odd, particularly since the paths are incorrect. I’m curious what others do.

cfleming 2023-06-22T03:49:22.795509Z

So weirdly, the deps are correct but the paths are not. I suspect this is because the alias uses :deps rather than :extra-deps. I guess the paths are not a problem as long as your build is in a single file.

seancorfield 2023-06-22T03:49:44.550099Z

I guess it depends on how isolated you need it to be while working on it. You could use -Sdeps '{:paths ["."]}' I suspect.

cfleming 2023-06-22T03:50:40.574059Z

I guess so. Thanks for the info!

seancorfield 2023-06-22T03:52:46.648389Z

I tend to work on my build.clj files alongside the project files so I want "src" etc as my paths -- nothing in my build.clj files relies on the paths being just "."

cfleming 2023-06-22T03:54:17.552899Z

That wouldn’t work for me without something like the -Sdeps trick, since I slurp config files from the path.

cfleming 2023-06-22T03:54:56.962339Z

Actually, that would work as long as the CWD is set correctly, I guess only resource loading would be affected.

seancorfield 2023-06-22T04:05:46.343349Z

How do you normally start your REPL for working with code? Via Cursive, I'd assume, with nREPL etc?

cfleming 2023-06-23T00:10:58.704989Z

Yes, either nREPL or socket REPL. But right, this is all part of a large change I’m making to how Cursive uses deps. I’m going to use deps.clj, which will make it easier to just allow people to enter the same things they’d enter on the command line to start their REPLs, and it’ll work more like the CLI than my current frankenintegration.

👍 1
👍🏻 1