Fork me on GitHub
#tools-deps
<
2021-04-27
>
didibus05:04:12

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

golanweiss11:04:16

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

borkdude12:04:15

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?

alexmiller12:04:19

You can combine, will use the last one iirc

borkdude12:04:02

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

alexmiller12:04:09

:mvn/local-repo

borkdude12:04:33

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

alexmiller12:04:45

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

simongray12:04:05

If I run clj -M -m .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
borkdude12:04:10

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

alexmiller12:04:07

No, I think it’s just an oversight

alexmiller12:04:15

I can add it

❤️ 2
seancorfield16:04:51

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.

borkdude12:04:08

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

simongray12:04:56

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
simongray13:04:22

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.

borkdude12:04:16

repro or it didn't happen :)

simongray13:04:19

kinda in the middle of a bunch of changes :S

simongray13:04:21

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)?

seancorfield16:04:02

Because -M means “run clojure.main” and -m is an option to clojure.main itself (as are -i, -e, and -r).

Darin Douglass16:04:46

was the decision to provide only short-form arguments for clj deliberate? having better-reading commands would, IMO, alleviate a good portion of the -M v -X v -A mixups. long-form arguments are definitely not magic pill for this style problem, but after a cursory think, i can't really think of a downside to having them

borkdude13:04:55

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

simongray13:04:39

Or maybe -M -x 😛

borkdude13:04:50

M x of course!

simongray13:04:05

all paths lead to emacs

borkdude13:04:06

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

seancorfield16:04:02

Because -M means “run clojure.main” and -m is an option to clojure.main itself (as are -i, -e, and -r).

Darin Douglass16:04:46

was the decision to provide only short-form arguments for clj deliberate? having better-reading commands would, IMO, alleviate a good portion of the -M v -X v -A mixups. long-form arguments are definitely not magic pill for this style problem, but after a cursory think, i can't really think of a downside to having them

borkdude17:04:27

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

clojure -A:foo:bar exec <exec-fn>
clojure -A:foo:bar main <foo.bar>
clojure -A:foo:bar path ;; print classpath
clojure -A:foo:bar run <tool>
clojure -A:foo:bar pom ...

borkdude17:04:54

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 Douglass17:04:22

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`)

borkdude17:04:31

In the case of

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

alexmiller17:04:50

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

borkdude21:04:56

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

☝️ 1
alexmiller21:04:27

oh sure, it might be inscrutable :)

alexmiller21:04:55

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

Alexis Vincent23:04:43

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 Vincent23:04:23

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 Vincent23:04:20

clojure -Spath prints src:resources:<...rest>

seancorfield23:04:56

@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.

seancorfield23:04:24

(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)

seancorfield23:04:33

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 Vincent23:04:43

@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 Vincent23:04:46

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

1
seancorfield23:04:51

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

seancorfield23:04:14

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