Fork me on GitHub
#tools-deps
<
2020-07-06
>
dominicm10:07:57

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

dominicm10:07:35

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

fabrao11:07:34

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"]}}
?

fabrao11:07:31

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

fabrao11:07:59

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

borkdude12:07:13

@fabrao try escaped double quotes around the IP

fabrao13:07:23

@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

fabrao13:07:58

I tried with ' too, not working

Alex Miller (Clojure team)14:07:37

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

fabrao14:07:07

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)

Alex Miller (Clojure team)14:07:02

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

Alex Miller (Clojure team)14:07:44

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

fabrao14:07:55

let me try

Alex Miller (Clojure team)14:07:02

I can't repro what you're getting

Alex Miller (Clojure team)14:07:14

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

Alex Miller (Clojure team)14:07:37

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

borkdude14:07:28

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

borkdude14:07:01

linux, macOS, Windows?

markbastian14:07:50

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?

seancorfield15:07:16

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

👌 3
🙏 3
Alex Miller (Clojure team)15:07:07

And repositories and source dir

seancorfield15:07:45

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

seancorfield15:07:21

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)

markbastian15:07:32

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.

seancorfield15:07:21

Per clojure -h:

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

seancorfield15:07:03

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.

fabrao15:07:55

: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

seancorfield15:07:00

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

borkdude15:07:30

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

borkdude15:07:53

oh no, that makes the EDN file invalid

borkdude15:07:02

try two \"'s

borkdude15:07:35

or just try WSL2 🙂

borkdude15:07:07

but I suspect doubling the double quotes works

fabrao15:07:55

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

borkdude15:07:38

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

seancorfield15:07:57

I am pretty sure the same recommendations apply...

fabrao15:07:44

sorry ->

Error: Could not find or load main class 10.10.20.82

fabrao15:07:57

Caused by: java.lang.ClassNotFoundException: 10.10.20.82

seancorfield15:07:25

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

seancorfield15:07:37

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

fabrao15:07:02

with \\" didn´t work too

seancorfield15:07:02

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

borkdude16:07:40

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

seancorfield20:07:38

Technically that is tripling the escaped quotes

borkdude20:07:14

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

seancorfield20:07:51

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

borkdude16:07:59

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

seancorfield16:07:33

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

seancorfield16:07:39

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.

cap10morgan18:07:10

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

borkdude18:07:08

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

seancorfield18:07:47

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

👍 3
seancorfield18:07:15

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

seancorfield18:07:24

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

cap10morgan18:07:53

Great. Thanks!

fabrao19:07:23

@borkdude It worked !!! Strange things

borkdude19:07:21

@fabrao Might be good to add to the wiki.

Spencer Apple23:07:53

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

seancorfield23:07:20

Aliases do not compose.

👍 3
Spencer Apple23:07:26

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

Spencer Apple23:07:32

that confused me

seancorfield23:07:42

Right, that means across all the aliases you specified.

Spencer Apple23:07:52

ah gotcha, thanks for the help!

seancorfield23:07:08

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

seancorfield23:07:18

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

👀 3
Spencer Apple23:07:56

great, this seems like a good solution! And thanks for the quick answer 😄

seancorfield23:07:40

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

Spencer Apple23:07:41

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

seancorfield23:07:50

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

👍 3