Fork me on GitHub
#tools-deps
<
2021-07-26
>
flowthing07:07:33

There seems to be a weird issue related to -X and futures with Clojure CLI 1.10.3.929:

$ clojure --version
Clojure CLI version 1.10.3.929
$ clojure -Srepro -X clojure.core.server/start-server :name '"server"' :port 5555 :accept clojure.core.server/repl :server-daemon false
$ clojure -Srepro -J-Dclojure.server.repl="{:port 6666 :accept clojure.core.server/repl}"
$ nc localhost 5555
user=> (def x (future 1))
Execution error (RejectedExecutionException) at java.util.concurrent.ThreadPoolExecutor$AbortPolicy/rejectedExecution (ThreadPoolExecutor.java:2057).
Task java.util.concurrent.FutureTask@14c75e2b[Not completed, task = clojure.core$binding_conveyor_fn$fn__5772@4f4cba65] rejected from java.util.concurrent.ThreadPoolExecutor@5d5b17a8[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1]
$ nc localhost 6666
user=> (def x (future 2))
#'user/x
That is, future throws when connecting to a socket REPL server started via -X, but not when connecting to a socket REPL server started via the clojure.server.repl system property.

flowthing07:07:23

I cannot reproduce the issue with 1.10.3.875.

flowthing07:07:38

The -X invocation doesn't work at all on 1.10.3.882, so I can't (easily) narrow it down any further.

seancorfield14:07:33

I can repro but can't explain the difference @U4ZDX466T You should put this up on http://ask.clojure.org so it doesn't get lost as Slack drops history.

flowthing14:07:55

Sure, will do later today.

greg09:07:00

What's your take on putting aliases within project deps.edn vs home's .clojure/deps.edn? I understand that some of the tools vary among Clojure devs (REBL/reveal, srepl/nrepl, IDEs/editors), so make sense to keep them locally specific, but lots of stuff could be shared, plus it is nice to have a sensible defaults for any newcomers. What your thoughts on this one? What kind of aliases do you shares within your projects' deps.edn?

seancorfield14:07:03

@grzegorz.rynkowski I think the project deps.edn should contain only aliases relevant to the project itself. If you want a "shared .clojure/deps.edn file", create a separate repo for that (and, now, any standard "tools" you want them to have installed, if you're starting them on the latest prerelease), and have them set up their environment based on that.

borkdude14:07:36

I don't know the right answer to "I want to check my emacs settings into your open source project so it does the right thing when I open CIDER", but I generally tell people to just document this for whoever wants to use it, instead of committing it in the project

borkdude14:07:33

On the the other hand, I sometimes see some IDEA settings in open source Clojure or Java projects 🀷

borkdude14:07:35

what if the next person wants a slightly different .idea or .gitignore?

borkdude14:07:15

But when it comes to .lsp or .clj-kondo config, I do think it belongs into the project, since it's about the code itself and improves the tooling related to the code.

borkdude14:07:23

I think there might be a grey area there

borkdude14:07:10

@deleted-user as an aside: I avoid the usage of the magic "jack-in" stuff

borkdude14:07:24

I always start a REPL in a terminal and then connect to them manually

borkdude14:07:59

why? because I don't want to have my dev process as a child of whatever editor. when I close my editor or open a too big of an XML file, I have to restart my dev process. too brittle.

borkdude14:07:12

also I don't want to rely on whatever deps gets injected by the tooling.

seancorfield14:07:15

My team start their REPL and then connect their editor to it. It's definitely our preferred approach. Partly because REPLs tend to outlive the editor and partly because you know exactly how the REPL is getting started instead of some "jack-in magic".

βž• 2
borkdude14:07:28

That's what I said ;)

seancorfield14:07:38

(and this really isn't about #tools-deps stuff -- greg's original Q was)

borkdude14:07:05

I think I still don't understand lein profiles

ghadi14:07:36

Pretty sure no one does

borkdude14:07:44

although I am using them, they are a bit magic when it comes to whatever profile is active when

borkdude14:07:07

in deps.edn this is fully explicit and I like that

borkdude14:07:08

A jar doesn't have system properties set. You have to set those when you invoke the jar, I think?

borkdude14:07:19

unless you use some properties file and a tool that reads it perhaps?

borkdude14:07:37

you can use environment variables for this

borkdude14:07:09

Java properties also work

borkdude14:07:15

but it depends when you capture and process those

dpsutton14:07:37

for those dev tooling, i'd probably just check if those namespaces were available, and if so, use the middleware with requiring resolve. Then jars wouldn't have those dev deps and you don't even need to configure anything

borkdude14:07:48

@deleted-user you want specific ring middleware for development, is this the problem?

seancorfield14:07:42

I would put the dev-specific stuff in a :dev alias and use that when developing (and it would be omitted when building the JAR).

☝️ 2
borkdude14:07:55

I don't see how this related to lein or deps.edn specifically, but there are ways to get this done through a dev profile/alias

seancorfield14:07:52

Jack-in can be told to use aliases.

seancorfield15:07:05

But my advice would be to stop using "magic".

borkdude15:07:31

I don't recommend the jack-in stuff but I think you can configure the tooling to use a specific alias ;)

seancorfield15:07:59

It's much harder to optionally exclude stuff than to optionally include other stuff.

borkdude15:07:00

the CIDER docs will probably have some entry for this

borkdude15:07:20

calva also has something for this, I bet

dpsutton15:07:05

you can ask in #clojure or somewhere. we can help you through things. But seems like this is getting towards generic project management rather than specific tools-deps questions

borkdude15:07:50

( I googled for: CIDER dev alias clojure )

pez15:07:02

You can also ask in #calva , w/o the jack-in hate added to the answers, even. πŸ˜€

seancorfield15:07:54

Re: JAR building -- if you can get to the place where you use -M:dev for dev/test and -M:prod for production, you can use the :prod alias when building the JAR.

borkdude15:07:17

@deleted-user if you need to persist settings in a jar, the only way is to flush them to a file in the resources, e.g. under META-INF/my-tool/settings.edn

borkdude15:07:48

or to assemble some clojure file using templating or so

borkdude15:07:07

when you (def foo (System/getProperty "build.time-property")) this won't be captured and written into the jar somehow

borkdude15:07:18

next time you run the jar, the property is gone

seancorfield15:07:35

(for what it's worth, we run our code in dev/test, the same way it would run in production -- without any special middleware etc -- partly to avoid these problems and also, mostly, to avoid "works-in-dev, break-in-production" issues)

dpsutton22:07:37

was gonna ask this on http://ask.clojure.org but i don't see a category for tools.build in the dropdown and that's giving me pause if that's a good place for prerelease version. But i'm observing the following error > /var/folders/h/3fpgc8pj4fb2w3mfqfl59fr0000gn/T/uber10889152638484484/license/LICENSE (Not a directory) and the stacktrace

build=> (b/uber {:class-dir class-dir
                 :uber-file "uberjar.jar"
                 :basis     basis})
FileNotFoundException /var/folders/_h/3fpgc8pj4fb2_w3mfqfl59fr0000gn/T/uber5850854519152411962/license/LICENSE (Not a directory)
	java.io.FileOutputStream.open0 (FileOutputStream.java:-2)
	java.io.FileOutputStream.open (FileOutputStream.java:298)
	java.io.FileOutputStream.<init> (FileOutputStream.java:237)
	java.io.FileOutputStream.<init> (FileOutputStream.java:187)
	clojure.tools.build.tasks.uber/explode (uber.clj:66)
	clojure.tools.build.tasks.uber/explode (uber.clj:53)
	clojure.tools.build.tasks.uber/uber/fn--16677 (NO_SOURCE_FILE:636)
	clojure.core/run!/fn--8813 (core.clj:7717)
	clojure.core.protocols/naive-seq-reduce (protocols.clj:62)
	clojure.core.protocols/interface-or-naive-reduce (protocols.clj:72)
	clojure.core.protocols/fn--8181 (protocols.clj:169)
	clojure.core.protocols/fn--8181 (protocols.clj:124)

seancorfield22:07:23

Out of curiosity, if you add depstar as a library, and use hf.depstar.api/uber instead of t.b.api/uber, does it work? (It should be API-compatible)

dpsutton22:07:50

i'll have to try unfortunately. but i'm quite interested in that

dpsutton22:07:04

i suspect this is happening when another license/LICENSE exists already

seancorfield22:07:41

Could be. I think there's already a bug open against t.b.a/uber for problems with multiple instances of a file.

seancorfield22:07:21

It doesn't concatenate license or notice files right now (it should). It doesn't handle log4j2 plugin cache files either. But I think that's all on the roadmap.

dpsutton22:07:30

off to jira

seancorfield22:07:51

The end goal is, in theory, that depstar can be retired in favor of t.b.a πŸ™‚

dpsutton19:07:10

depstar worked a treat. i think the filesystem as an intermediate can be tricky when going from case sensitive jars, possibly case sensitive FS, back to case insensitive jars

seancorfield20:07:02

@U11BV7MTK If you're on Windows, try building an uberjar with tools.build for a project that depends on uncomplicate/neanderthal πŸ™‚

seancorfield20:07:06

It contains an aux.clj file, which is a reserved name on Windows -- so you can't explode the neanderthal library to a directory and then copy it all into a JAR.

seancorfield20:07:33

https://github.com/seancorfield/depstar/issues/8 -- that was a big part of why I stopped doing that step.

seancorfield20:07:22

(I haven't checked whether Neanderthal has renamed that namespace - it might have)

dpsutton20:07:39

haha that is not fun at all πŸ™‚. i don't have access to a windows box unfortunately though

seancorfield20:07:35

I do but it isn't set up for Clojure on the Windows side -- only on the WSL2 side, otherwise, I'd verify that the above issue exists with tools.build and log a bug if it still happens...

blueberry22:07:35

@U04V70XH6 I renamed aux.clj to auxil.clj long time ago (due to this unfortunate Windows behavior).

seancorfield22:07:19

@U086AG324 Good to know! Thank you! It's weird that after all these decades, Windows still treats several filenames as reserved...

dpsutton23:07:41

i think that's really cool of them to take backwards compatibility so seriously. gotta respect that com binaries from the 80s still run on windows 10

seancorfield23:07:53

looks for an emoji for stagecoach or something similarly old... πŸ™‚

dpsutton22:07:34

it seems this is from the jar .m2/repository/xml-apis/xml-apis-ext/1.3.04/xml-apis-ext-1.3.04.jar which has an entry for license/LICENSE.

seancorfield22:07:00

I'd say put it on ask with the tools.deps category...

dpsutton22:07:36

i'm not seeing that here

dpsutton22:07:41

or is that a tag?

seancorfield22:07:49

Category Contrib

πŸ‘ 2
seancorfield22:07:29

And I see tools.build under Contrib so you should be able to tag it that way.

dpsutton22:07:43

you are 100% correct. thanks sean