tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
zetafish 2020-10-05T17:13:59.186800Z

Hi all, I try to create an uberjar with depstar using the -X method. I.e. i updated my deps.edn to have an alias specifying a exec-fn and exec-arg. When running on my laptop clojure -X:uberjar a jar is generated just fine. However when I try to create the jar from a docker container it fails with

Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
-X:uberjar (No such file or directory)
The docker images I tried:
clojure:openjdk-11-tools-deps-1.10.1.469
clojure:openjdk-11-tools-deps-1.10.1.561

alexmiller 2020-10-05T17:20:48.187200Z

you don't have the newest clj tools in your docker

alexmiller 2020-10-05T17:21:06.187500Z

you need clojure 1.10.1.697

seancorfield 2020-10-05T17:57:39.188800Z

@zetafish I'm planning an overhaul of my project's readme files this week to make that clearer (that some of the usage examples require 1.10.1.697). I also need to update all of the clj-new project stuff to generate projects that can work both ways.

kirill.salykin 2020-10-05T18:17:42.189400Z

what do you think about https://github.com/juxt/pack.alpha?

kirill.salykin 2020-10-05T18:18:59.190800Z

it has interesting feature skinny jar

dominicm 2020-10-05T18:19:07.191300Z

Is clojure.libfile still present in 697?

seancorfield 2020-10-05T18:27:18.192100Z

I don't see it in the system properties when running code via 1.10.1.697 @dominicm -- there's clojure.basis now, which is the path to the combined EDN file.

seancorfield 2020-10-05T18:28:42.192600Z

I see it was still present in 590:

> /usr/local/Cellar/clojure\@1.10.1.590/1.10.1.590/bin/clojure
Clojure 1.10.1
user=> (System/getProperty "clojure.libfile")
"/Users/sean/.clojure/.cpcache/2731801087.libs"
user=> 

dominicm 2020-10-05T18:28:57.193100Z

Ah, that could explain the bug I'm seeing. I thought it was being retained for backwards compatibility.

seancorfield 2020-10-05T18:59:27.195800Z

@dominicm Lots of breakage between the previous stable and the current stable πŸ™‚ but if you change (System/getProperty "clojure.libfile") to (some-> (System/getProperty "clojure.basis") (str/replace #"\.basis$" ".libs")) you can still get at the old file (although, as I recall, the basis file now contains the libs list as an element?)

seancorfield 2020-10-05T19:01:44.196700Z

Yeah, (some-> (System/getProperty "clojure.basis") (slurp) (edn/read-string) :libs) should be the same data.

alexmiller 2020-10-05T19:50:28.197900Z

yeah, I removed it in 697. we've never publicly doc'ed it and I was not aware of anyone using it (other than add-libs which won't work with latest anyways) so I didn't think there was any reason to retain it

dominicm 2020-10-05T19:51:52.198600Z

I was using it to find myself on the classpath and remove my paths

zetafish 2020-10-05T19:52:00.198700Z

Thank you Alex. I presume the 697 image will become available on docker hub soon. In the meantime I built the image locally and the -X:uberjar works fine then.

zetafish 2020-10-05T19:54:15.199Z

I want a self contained jar that I can run with java -jar app.jar so skinny does not fit the bill.

alexmiller 2020-10-05T20:00:51.199600Z

I'd say separating the tool from the basis is the better long term path for that

alexmiller 2020-10-05T20:01:11.199900Z

we have an ongoing conversation about some details of that right now

alexmiller 2020-10-05T20:01:35.200Z

I don't have anything to do with the docker stuff, so no control over that for me

dominicm 2020-10-05T20:21:00.201Z

If I could reliably identify my lib in the classpath, then that'd be fine πŸ™‚. Happy to switch over to the newnew system when that comes out too.

dominicm 2020-10-05T20:21:15.201400Z

A github search indicates I'm probably the only user anyway

dominicm 2020-10-05T20:21:30.201800Z

We also use it in our internal tool based on the lib, but I can update that the same way

borkdude 2020-10-05T20:58:17.202900Z

@dominicm removing yourself from the classpath: is this for an uberjar tool maybe? accepting a classpath argument that's built using -Spath may also work - depstar now also supports it

dominicm 2020-10-06T07:13:47.242Z

It isn't, it's for excluding certain dependencies from the Figwheel build path. I do this at an application level, rather than library level.

seancorfield 2020-10-05T20:58:53.203500Z

(although depstar still removes itself from the classpath even if you provide that option, I believe)

borkdude 2020-10-05T20:59:08.203800Z

oh right - that doesn't seem necessary - building an uberjar with depstar in it could be useful

ghadi 2020-10-05T21:01:02.205300Z

As the original author of depstar, I consider the approach of removing self from the classpath adorable, but a design mistake

ghadi 2020-10-05T21:01:24.206100Z

Should use t.d.a API instead

βœ”οΈ 1
βž• 1
seancorfield 2020-10-05T21:02:13.206900Z

I doubt it would cause any surprises if I changed the behavior to only omit depstar from the (current) runtime classpath but allow it as part of the -P / --classpath path πŸ™‚

seancorfield 2020-10-05T21:03:29.208200Z

Using the t.d.a. API to read the various deps.edn files has problematic edge cases -- as we're seeing with -X:deps tree which includes t.d.a in the tree even when it isn't part of the project being analyzed.

seancorfield 2020-10-05T21:04:31.209600Z

It's also problematic for monorepo use cases -- where CLJ_CONFIG is used to point to a "master" deps.edn inside the repo, alongside each subproject's deps.edn -- which is something Datomic Ions folks do I believe (in addition to us relying heavily on it at work).

borkdude 2020-10-05T21:05:16.210400Z

also, --classpath can be calculated using other build tools like lein, boot, maven, whatever, which makes it connectable with other ecosystems

vlaaad 2020-10-05T21:05:18.210500Z

Isn't -X:deps tree misreport deps because of the same design mistake?

seancorfield 2020-10-05T21:06:49.211400Z

clojure -Stree works correctly, clojure -X:deps tree does not.

ghadi 2020-10-05T21:08:25.213Z

Bugs aside, use the API

vlaaad 2020-10-05T21:08:49.214Z

But that is because it uses the basis of its invocation instead of calculating the classpath using its capabilities to do so

ghadi 2020-10-05T21:08:55.214400Z

(Aside, is CLJ_CONFIG isn’t public API?)

seancorfield 2020-10-05T21:09:38.215200Z

I don't have an argument against computing a classpath separately and providing it to a tool -- but that's orthogonal to the issue of figuring out the classpath for a tool to use. If t.d.a is enhanced to better support monorepos that need a way to have an additional deps.edn file in the mix (and then exclude the actual user deps.edn) I'll happily switch to that.

seancorfield 2020-10-05T21:10:29.216200Z

@ghadi Yes, CLJ_CONFIG is definitely a "hack", but it's a useful hack in the absence of t.d.a supporting an additional deps.edn in a monorepo context.

borkdude 2020-10-05T21:12:28.216900Z

isn't the user deps.edn excluded by -Srepro?

borkdude 2020-10-05T21:12:34.217200Z

as in user home dir

seancorfield 2020-10-05T21:12:41.217400Z

Right, but that excludes CLJ_CONFIG.

borkdude 2020-10-05T21:13:58.219100Z

deps.clj has an option called -Sdeps-file: https://github.com/borkdude/deps.clj I haven't really thought about the consequences for relative paths, but if you don't use those, it should work

borkdude 2020-10-05T21:15:01.219900Z

but ( cd ...; clojure ...) also works

borkdude 2020-10-05T21:17:15.221300Z

my colleague also started using CLJ_CONFIG the same week he started using clj because of this limitation

borkdude 2020-10-05T21:17:23.221600Z

just feedback, no criticism ;)

borkdude 2020-10-05T21:18:32.222900Z

I wonder, if it's undocumented, he sure found it pretty quickly somewhere, I didn't tell him about it

seancorfield 2020-10-05T21:20:48.225300Z

The problem with that (getting a file from the command line) is that the desired order for repos such as ours is:

System -> User (happy to exclude with -Srepro) -> repo-master (this is missing) -> Project -> -Sdeps
and because "last one wins" etc for some combinations of aliases, you can't always specify "repo-master` via some sort of -Sdeps-file option.

seancorfield 2020-10-05T21:24:14.227200Z

Although, if you could specify an arbitrary list of files to read in order via -Sdeps-file (and they didn't have to be called deps.edn) then we could use -Sdeps-file ../versions/master-deps.edn:project-deps.edn and not have an actual deps.edn file in each subproject in the repo.

borkdude 2020-10-05T21:25:46.227900Z

-Sdeps-path might be a more appropriate name and I'd be happy to support it in deps.clj (and change the name). It already does this now but for just one file

borkdude 2020-10-05T21:27:10.229200Z

-Sdeps-overrides could also work as a name to indicate that it doesn't read any other files than these

borkdude 2020-10-05T21:29:55.230100Z

but I'm relatively sure all of this can be done using scripting as well: merge the configs yourself, provide it via -Sdeps and move the local deps.edn aside (hacky)

borkdude 2020-10-05T21:31:22.230700Z

also I'm relatively sure these things are in some row/column in an excel sheet somewhere on Alex's computer :)

seancorfield 2020-10-05T21:37:46.231600Z

Our deps files are pretty big -- too big to go on the command line I think as merged data -- and, as you say, that's a hacky approach.

seancorfield 2020-10-05T21:39:11.232900Z

(also, we're not about to switch from the official Clojure CLI to a third party tool at this point, esp when we would need multiple different binaries for different parts of our dev/test/staging pipeline, whereas we can have just one CLI install)

seancorfield 2020-10-05T21:41:20.235Z

And, yeah, I've already brought this up with Alex (which was how I learned that it's similar to something the Datomic Ions users have asked for) so, yeah, I'll bet it's already in a spreadsheet. I don't know what I'd prefer in terms of a solution. As long as it addresses the deps ordering shown above and is officially supported, I'll be happy with whatever Cognitect/Nubank think is the best approach πŸ™‚

borkdude 2020-10-05T21:43:38.236Z

@seancorfield small details: deps.clj also runs using clojure / JVM as a dependency but yeah I don't expect you to switch - I was just thinking out loud about this option. I'm blathering too much.

seancorfield 2020-10-05T22:01:02.236500Z

Ah, true, I'd forgotten there was a library version as well...

borkdude 2020-10-05T22:01:52.237500Z

I just pushed 0.0.10 - there was something with the clojars deploy token, missed that. But now it works:

/tmp $ clojure -Sdeps '{:deps {borkdude/deps.clj {:mvn/version "0.0.10"}}}' -M -m borkdude.deps -Sdeps-file "$HOME/git/clojurescript/deps.edn" -Spath
src/main/clojure:src/main/cljs:resources:/Users/borkdude/.m2/repository/com/cognitect/transit-clj/0.8.309/transit-clj-0.8.309.jar:/Users/borkdude/.m2/repository/com/google/javascript/closure-compiler-unshaded/v20180805/closure-compiler-unshaded-v20180805.jar:...

borkdude 2020-10-05T22:02:37.238Z

(so I'm in /tmp, but I'm using deps.edn from clojurescript in $HOME/git/clojurescript)

alexmiller 2020-10-05T23:47:16.239600Z

Just putting this here for now, but there is a new prerelease clj available - 1.10.1.708. Has a small fix to -X error handling and more importantly an update on how dep expansion works when multiple transitive versions of the same dep are in the tree to fix a case where a dep can be incorrectly omitted.

seancorfield 2020-10-07T16:45:21.252Z

I'm about to update things here...

seancorfield 2020-10-07T18:52:55.252200Z

Building our uber JARs for our 14 processes seems to produce near-identical results between .697 and .708 -- there are variations from run-to-run based (I assume) on differing timestamps etc but nothing more than 150 bytes on JAR files that range from 30MB to 70MB, so that all looks reasonably sane.

seancorfield 2020-10-07T18:53:56.252400Z

(if dependencies were missing we'd have known about it by now on .697 and 150 bytes here and there isn't likely to indicate an entire dependency coming or going)

alexmiller 2020-10-07T18:59:12.252600Z

yeah, shouldn't be anything different other than the set of jars selected

alexmiller 2020-10-05T23:49:12.241100Z

The circumstances for the latter case are quite complicated so it's a little challenging for me to categorically say whether your deps are affected (they probably aren't), but if you were were interested in trying it, would be happy to have any feedback before I make it stable.

πŸ‘ 1
❀️ 6