tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
dominicm 2020-07-06T10:36:57.230200Z

Oh really? Interesting. I'd been resolving each dependency independently and comparing to the top level. Your idea is better.

dominicm 2020-07-06T10:37:35.231300Z

I wonder if you could build a whole lint suite out of the trace, catching other common errors (hello Jackson and jetty).

fabrao 2020-07-06T11:40:34.232300Z

Hello all, how to listen in all interfaces for this

:aliases {:dev {:jvm-opts ["-Dclojure.server.repl={:port,5555,:accept,clojure.core.server/repl} -Dfile.encoding=UTF-8"]}}
?

fabrao 2020-07-06T11:42:31.233Z

I tried :address,10.10.20.whatever and it didn´t work

fabrao 2020-07-06T11:45:59.233200Z

-> Exception in thread "main" java.lang.NumberFormatException: Invalid number: 10.10.20.82

borkdude 2020-07-06T12:33:13.233800Z

@fabrao try escaped double quotes around the IP

fabrao 2020-07-06T13:09:23.234400Z

@borkdude :aliases {:dev {:jvm-opts ["-Dclojure.server.repl={:port,5555,:address,\"10.10.20.82\",:accept,clojure.core.server/repl} -Dfile.encoding=UTF-8"]}} -> same error

fabrao 2020-07-06T13:09:58.234800Z

I tried with ' too, not working

alexmiller 2020-07-06T14:02:37.235400Z

that seems weird to me. can you share the full output?

fabrao 2020-07-06T14:16:07.235800Z

Exception in thread "main" java.lang.NumberFormatException: Invalid number: 10.10.20.82
        at clojure.lang.EdnReader.readNumber(EdnReader.java:224)
        at clojure.lang.EdnReader.read(EdnReader.java:136)
        at clojure.lang.EdnReader.readDelimitedList(EdnReader.java:766)
        at clojure.lang.EdnReader$MapReader.invoke(EdnReader.java:680)
        at clojure.lang.EdnReader.read(EdnReader.java:145)
        at clojure.lang.EdnReader.read(EdnReader.java:111)
        at clojure.lang.EdnReader.readString(EdnReader.java:67)
        at clojure.edn$read_string.invokeStatic(edn.clj:46)
        at clojure.edn$read_string.invokeStatic(edn.clj:37)
        at clojure.core.server$parse_props$fn__8907.invoke(server.clj:152)
        at clojure.core.protocols$naive_seq_reduce.invokeStatic(protocols.clj:62)
        at clojure.core.protocols$interface_or_naive_reduce.invokeStatic(protocols.clj:72)
        at clojure.core.protocols$fn__8159.invokeStatic(protocols.clj:169)
        at clojure.core.protocols$fn__8159.invoke(protocols.clj:124)
        at clojure.core.protocols$fn__8114$G__8109__8123.invoke(protocols.clj:19)
        at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:31)
        at clojure.core.protocols$fn__8136.invokeStatic(protocols.clj:75)
        at clojure.core.protocols$fn__8136.invoke(protocols.clj:75)
        at clojure.core.protocols$fn__8088$G__8083__8101.invoke(protocols.clj:13)
        at clojure.core$reduce.invokeStatic(core.clj:6828)
        at clojure.core.server$parse_props.invokeStatic(server.clj:146)
        at clojure.core.server$start_servers.invokeStatic(server.clj:157)
        at clojure.core.server$start_servers.invoke(server.clj:157)
        at clojure.lang.Var.invoke(Var.java:384)
        at clojure.lang.RT.doInit(RT.java:493)
        at clojure.lang.RT.init(RT.java:467)
        at clojure.main.main(main.java:38)

alexmiller 2020-07-06T14:20:02.237200Z

you need to put that second -D in a separate string

alexmiller 2020-07-06T14:21:44.237500Z

{:aliases {:dev {:jvm-opts ["-Dclojure.server.repl={:port,5555,:address,\"10.10.20.82\",:accept,clojure.core.server/repl}" "-Dfile.encoding=UTF-8"]}}}

fabrao 2020-07-06T14:21:55.237700Z

let me try

alexmiller 2020-07-06T14:22:02.237900Z

I can't repro what you're getting

alexmiller 2020-07-06T14:22:14.238200Z

I get an error binding that address, but that's to be expected

alexmiller 2020-07-06T14:26:37.238500Z

I would expect that error w/o the quotes around the address

borkdude 2020-07-06T14:27:28.239Z

@fabrao Are you doing this from a deps.edn file or from a cmd line with -Sdeps?

fabrao 2020-07-06T14:31:14.240700Z

deps.edn

borkdude 2020-07-06T14:34:01.242200Z

linux, macOS, Windows?

2020-07-06T14:39:50.245Z

From what I've read, it sounds like a fairly standard approach to publishing library artifacts with deps is to create a pom with clj -S:pom and then use mvn deploy. When you do this model, are there any best practices regarding how to keep things in sync? For example, do you: 1. Regenerate the pom every time you want to cut a release? This seems wrong as you lose all of your version and other info. 2. Generate the pom once and then maintain it? This seems like a good route, but the main downside I see is keeping dependencies in sync. I am assuming #2 is the best option. Any tips for syncing dependencies?

seancorfield 2020-07-06T15:35:16.245700Z

@markbastian clojure -Spom does not overwrite anything in your pom.xml except <dependencies>

👌 1
🙏 1
seancorfield 2020-07-06T15:35:45.246300Z

And for publishing to Clojars, you really need a lot more in your pom.xml file than clojure -Spom provides.

seancorfield 2020-07-06T15:38:21.249400Z

If you create a new project with clj-new (typically clj -A:new lib myname/myproject) it will have a suitable pom.xml file and then for each release you just run clojure -Spom, update the version and tag in the pom for the upcoming release, commit and push those pom changes, add a release on GitHub and pull, clojure -A:jar (because clj-new makes that alias available), and then clojure -A:deploy (again, from clj-new's template)

2020-07-06T15:39:32.250400Z

Ah, I hadn't realized what the pom command did. I thought it generated a pom (replacing the existing). I just did an experiment based on your comment and suddenly things make a lot more sense. Very cool! Thanks for the info.

seancorfield 2020-07-06T15:40:03.251500Z

The :jar alias is for depstar and it gets the group, artifact, and version from pom.xml and builds everything you need inside the .jar incl. manifest, multi-release, etc.

fabrao 2020-07-06T15:40:44.252500Z

@borkdude It´s Windows

fabrao 2020-07-06T15:40:55.253100Z

:aliases {:dev {:jvm-opts ["-Dclojure.server.repl={:port,5555,:address,\"10.10.20.82\",:accept,clojure.core.server/repl}" "-Dfile.encoding=UTF-8"]}} didn´t work

borkdude 2020-07-06T15:40:56.253200Z

aaah

seancorfield 2020-07-06T15:41:00.253400Z

The :deploy alias is for deps-deploy and it expects

CLOJARS_PASSWORD=<your secret>
CLOJARS_USERNAME=<your username>
to be set in your env vars

borkdude 2020-07-06T15:41:30.253900Z

@fabrao windows is a bit different here maybe. can you try "" instead of \"?

borkdude 2020-07-06T15:41:53.254100Z

oh no, that makes the EDN file invalid

borkdude 2020-07-06T15:41:54.254300Z

hmm

borkdude 2020-07-06T15:42:02.254500Z

try two \"'s

seancorfield 2020-07-06T15:42:21.254700Z

Per clojure -h:

-Spom           Generate (or update an existing) pom.xml with deps and paths

borkdude 2020-07-06T15:43:35.255Z

or just try WSL2 🙂

borkdude 2020-07-06T15:44:07.255300Z

but I suspect doubling the double quotes works

fabrao 2020-07-06T15:44:55.255900Z

\"\"10.10.20.82\"\" and ""10.10.20.82"" -> Invalid Number

seancorfield 2020-07-06T15:45:06.256200Z

Or perhaps just read the t.d.a. wiki about Windows? https://github.com/clojure/tools.deps.alpha/wiki/clj-on-Windows#escaping-quotes

borkdude 2020-07-06T15:45:38.256500Z

@seancorfield he isn't using -Sdeps from the command line, this is in an EDN file

seancorfield 2020-07-06T15:45:57.257Z

I am pretty sure the same recommendations apply...

fabrao 2020-07-06T15:46:44.257500Z

sorry ->

Error: Could not find or load main class 10.10.20.82

fabrao 2020-07-06T15:46:57.258Z

Caused by: java.lang.ClassNotFoundException: 10.10.20.82

seancorfield 2020-07-06T15:47:25.258700Z

@fabrao There's a #clj-on-windows channel that has real Windows users that have probably solved this problem. You're just kind of flailing right now...

alexmiller 2020-07-06T15:48:07.259100Z

And repositories and source dir

fabrao 2020-07-06T15:48:28.259600Z

ok Sean

seancorfield 2020-07-06T15:48:37.259800Z

(I would probably try \\" in the string in deps.edn tho')

fabrao 2020-07-06T15:51:02.260100Z

with \\" didn´t work too

seancorfield 2020-07-06T15:52:02.261Z

I'm firing up a Windows VM. I'll try a few years and report back in #clj-on-windows

borkdude 2020-07-06T16:01:40.261800Z

@fabrao, this worked for me on Windows:

{:aliases {:dev {:jvm-opts ["-Dclojure.server.repl={:port,5555,:address,\"\"\"127.0.0.1\"\"\",:accept,clojure.core.server/repl}" "-Dfile.encoding=UTF-8"]}}}
so doubling the escaped quotes, just like I suspected 😎

borkdude 2020-07-06T16:01:59.262100Z

and I verified with netstat that the server was indeed running with clojure -A:dev

seancorfield 2020-07-06T16:19:33.266400Z

(sorry, got distracted by a phone call with my mum in England, but I was getting there I hope...)

seancorfield 2020-07-06T16:39:39.268300Z

FWIW, that format with \"\"\" around the host IP seems to work on Linux and macOS as well. Which surprised me a bit. I was able to start a REPL with that alias on Powershell, CMD (via powershell clj), and WSL -- as well as on macOS (Terminal) -- and connect to it via telnet to verify the socket REPL connection.

cap10morgan 2020-07-06T18:18:10.269200Z

Is there a way to just install the deps w/ tools-deps? I'm looking for an equivalent to lein deps (for caching them in a Docker image build).

borkdude 2020-07-06T18:21:08.269900Z

@cap10morgan you can just do -Spath and will print the classpath, downloading the deps as a side effect

seancorfield 2020-07-06T18:27:47.270800Z

-Spath, -Stree, and -e nil seem to be the most commonly mentioned ways to have the CLI just download deps, optionally print some information about them, and just exit.

👍 1
seancorfield 2020-07-06T18:28:15.271400Z

I like -Stree myself since it's easier to read than -Spath if I want to verify the actual dependencies being used.

seancorfield 2020-07-06T18:28:24.271700Z

Or just -e nil if I don't care.

cap10morgan 2020-07-06T18:29:53.272Z

Great. Thanks!

fabrao 2020-07-06T19:36:23.272300Z

@borkdude It worked !!! Strange things

borkdude 2020-07-06T19:47:21.272800Z

@fabrao Might be good to add to the wiki.

seancorfield 2020-07-06T20:08:38.272900Z

Technically that is tripling the escaped quotes

borkdude 2020-07-06T20:09:14.273100Z

oh wait, I didn't even know I did that.

seancorfield 2020-07-06T20:09:51.273300Z

And weird that it seems to work across all platforms... 😐

borkdude 2020-07-06T20:11:45.273500Z

haha

2020-07-06T23:47:53.279300Z

With the monorepo root CLJ_CONFIG deps.edn

{:aliases {:dev {:jvm-opts ["-XX:-OmitStackTraceInFastThrow"]}}}
And a local deps.edn
{:aliases {:dev {:extra-deps {...}}
I can pull configuration from the monorepo root CLJ_CONFIG
CLJ_CONFIG=../.clojure clojure -A:dev
However, this doesn’t pass down the :jvm-opts from the CLJ_CONFIG deps.edn. Is this working as intended? Is there a better way to do this? (I could create another alias with this jvm-opt or perhaps use environment variables.)

seancorfield 2020-07-06T23:48:20.279700Z

Aliases do not compose.

👍 1
2020-07-06T23:49:26.280900Z

there’s a line in the guide: > If multiple maps with these keys are activated, `:jvm-opts` concatenate

2020-07-06T23:49:32.281200Z

that confused me

seancorfield 2020-07-06T23:50:18.282200Z

You can either have an alias in the user-level file (via CLJ_CONFIG) or in the project-level file. What we did is to have something like :dev-defaults in the user-level (monorepo) file and then :dev as an empty alias there and overridden in each project -- and then do CLJ_CONFIG=../defaults clojure -A:dev-defaults:dev

👀 1
seancorfield 2020-07-06T23:50:42.282300Z

Right, that means across all the aliases you specified.

2020-07-06T23:50:52.282500Z

ah gotcha, thanks for the help!

seancorfield 2020-07-06T23:51:08.282800Z

But they have to be different aliases. I answered in the main channel how we handle this at work.

seancorfield 2020-07-06T23:52:40.283800Z

We have about thirty subprojects in our monorepo (and over 100,000 lines of code overall).

2020-07-06T23:53:41.284900Z

Thank you for sharing your deps.edn btw, I should have studied that a bit more closely…

seancorfield 2020-07-06T23:55:50.285300Z

LMK if you have any Qs -- feel free to DM me any time about it.

👍 1