tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
2021-04-27T05:59:12.057700Z

I was thinking for lein projects, lein has a task to make a compatible pom.xml, but not to make a deps.edn I believe

golanweiss 2021-04-27T11:28:16.058200Z

if you mean how to convert lein -> deps I used https://github.com/hagmonk/depify

borkdude 2021-04-27T12:07:15.059Z

What is the proper way of invoking:

clojure -Sforce -A:backend:backend/prod:backend/build -X:backend/build
Can this be squashed into one -X:...? Of which alias is the exec fn chosen?

borkdude 2021-04-27T12:23:02.059500Z

What was the option again to specify a different local mvn .m2 dir?

alexmiller 2021-04-27T12:36:09.060200Z

:mvn/local-repo

alexmiller 2021-04-27T12:37:19.061100Z

You can combine, will use the last one iirc

borkdude 2021-04-27T12:53:33.061700Z

@alexmiller Is this a documented option? I couldn't find it

alexmiller 2021-04-27T12:54:45.062900Z

It’s part of the deps.edn, not a clj option

simongray 2021-04-27T12:56:05.063900Z

If I run clj -M -m <http://path.to.my|path.to.my>.main.ns lots of dependencies are downloaded. I thought running clojure -Spath beforehand would fetch those dependencies, but it doesn’t seem to do so?

✅ 1
borkdude 2021-04-27T12:56:10.064100Z

I know, but any reason this is not part of guides or references for deps_and_cli?

alexmiller 2021-04-27T12:57:07.064600Z

No, I think it’s just an oversight

alexmiller 2021-04-27T12:57:15.064800Z

I can add it

❤️ 2
borkdude 2021-04-27T12:58:08.065300Z

@simongray I think it would need to fetch those deps in order to calc the classpath, no?

simongray 2021-04-27T12:58:56.066100Z

You would think so, but it doesn’t seem to do that. The clojure -Spath runs inside a Docker container, so perhaps something is amiss

✅ 1
borkdude 2021-04-27T12:59:16.066300Z

repro or it didn't happen :)

simongray 2021-04-27T13:00:19.066500Z

kinda in the middle of a bunch of changes :S

simongray 2021-04-27T13:02:21.067700Z

Also, maybe someone can tell me why you need to do -M -m ? Or should I do -X now instead (the docs seem to use that now)?

borkdude 2021-04-27T13:03:55.068200Z

Or was it -X -x ? :thinking_face: :troll:

simongray 2021-04-27T13:04:39.068500Z

Or maybe -M -x 😛

borkdude 2021-04-27T13:04:50.068800Z

M x of course!

simongray 2021-04-27T13:05:05.069Z

all paths lead to emacs

borkdude 2021-04-27T13:06:06.069500Z

{:emacs {:replace-paths ["emacs"]}}
clojure -Spath -A:emacs 
M x clojure

simongray 2021-04-27T13:06:22.069700Z

hah

borkdude 2021-04-27T13:13:04.070Z

https://imgflip.com/i/57awpv ;)

😆 2
simongray 2021-04-27T13:23:22.070500Z

Solved: I didn’t set the WORKDIR in the Dockerfile before running clojure -Spath so there was no deps.edn to fetch download depencies according to.

seancorfield 2021-04-27T16:03:51.070900Z

I was trying to find that the other day in response to someone’s new-to-tools-deps question. It would be nice if the docs were also a little clearer that :mvn/repos and :mvn/local-repo can only be used at top-level keys and not inside aliases — that seems to be a fairly common confusion for some folks.

alexmiller 2021-04-27T16:22:17.071600Z

:thumbsup:

borkdude 2021-04-27T17:04:27.074700Z

@ddouglass Another option could be having subcommands instead of dashed options.

clojure -A:foo:bar exec &lt;exec-fn&gt;
clojure -A:foo:bar main &lt;foo.bar&gt;
clojure -A:foo:bar path ;; print classpath
clojure -A:foo:bar run &lt;tool&gt;
clojure -A:foo:bar pom ...

borkdude 2021-04-27T17:04:54.075200Z

so just one option to "compose" the classpath and subcommands that handle what should be done (with their own arg parsing and help output)

Darin Douglass 2021-04-27T17:07:22.077400Z

ya, i'm more preferential to that option b/c i think the current -A|M|X options are a bit overloaded which bring up questions (like your's earlier) like "which alias does exec-opts come from", etc. same thing for -S*: some are commands (`-Stree`) while some are options (`-Scp cp`)

borkdude 2021-04-27T17:08:31.078100Z

In the case of

clojure -A:foo:bar exec &lt;exec-fn&gt;
you would still have the ambiguity of where the exec-fn could come from (the last alias?)

Darin Douglass 2021-04-27T17:10:28.078800Z

mmhmm

alexmiller 2021-04-27T17:55:50.079500Z

It’s not ambiguous - there is a merge strategy defined for each

borkdude 2021-04-27T21:06:56.082100Z

I mean, from the point of the ignorant consumer of this CLI

☝️ 1
alexmiller 2021-04-27T21:20:27.082300Z

oh sure, it might be inscrutable :)

alexmiller 2021-04-27T21:21:55.083100Z

but generally I think <hand-wave> last one wins <hand-wave/> is what you expect most

Alexis Vincent 2021-04-27T23:22:43.086500Z

I’m a bit confused about something. I have a deps.edn with :paths ["src"] , but clojure.tools.namespace.repl/reset doesn’t work unless I (clojure.tools.namespace.repl/set-refresh-dirs "src") . Checking (clojure.java.classpath/classpath-directories) returns '(). I guess my expectation was that this would be set using :paths ?

Alexis Vincent 2021-04-27T23:26:23.087200Z

repl is started using cider via /usr/local/bin/clojure -A:dev -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.3"} refactor-nrepl/refactor-nrepl {:mvn/version "2.5.1"} cider/cider-nrepl {:mvn/version "0.25.9"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl

Alexis Vincent 2021-04-27T23:29:20.087700Z

clojure -Spath prints src:resources:&lt;...rest&gt;

seancorfield 2021-04-27T23:42:56.090400Z

@mail024 My advice would be to try to ween yourself off the t.n.r reset/reload workflow and develop a “better” REPL workflow that doesn’t need that sort of thing, i.e., eval’ing every change you make as you go so the REPL state is always fresh. I see a lot of people get into all sorts of problems with “reloaded” style workflows 😞 and folks like Eric Normand, Stu Halloway, Rich Hickey, myself, and many others avoid this sort of tooling.

seancorfield 2021-04-27T23:44:24.091800Z

(but it does sound like a but in java.classpath since src and resources are on the classpath and are directories — you could create a post on http://ask.clojure.org tagged with the java.classpath library and see what the library maintainers say)

seancorfield 2021-04-27T23:45:33.093Z

I would also recommend trying to repro in a plain REPL started yourself — without all that nREPL/CIDER stuff — and see if the problem persists: it’s entirely possible that something in nREPL/CIDER is causing this problem…

Alexis Vincent 2021-04-27T23:51:43.095700Z

@seancorfield Thanks. Appreciate the advice. Guess it’s an old habit. Will give the suggested approach a spin, been meaning to try life without ns refresh for a while now

Alexis Vincent 2021-04-27T23:53:46.096400Z

I’m thinking it might actually be a cider thing. plain repl has the expected entries in classpath-directories

1
seancorfield 2021-04-27T23:58:51.097600Z

I haven’t used nREPL or CIDER for a very long time so I would only point you to #cider at this point 🙂

seancorfield 2021-04-27T23:59:14.097900Z

(I use a plain Socket REPL with no additional dependencies)