tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
alexmiller 2020-12-03T03:28:48.144300Z

I just released a prerelease clj 1.10.1.745 with the new dep tree printing under clj -X:deps tree (want to get some feedback but I will extend to -Stree before I release it). Options available (won't be available under -Stree): β€’ :file <path> - make tree from a trace.edn file created by clj -Strace instead of the local deps.edn β€’ :indent <int> - tree spacing (default = 2) β€’ :hide-libs <set-of-libs> - libs to hide in the tree under the root, defaults to #{org.clojure/clojure}

alexmiller 2020-12-03T03:29:54.145Z

I'm also thinking about having a flag to choose whether to display excluded libs (-Stree does not, the new format does)

alexmiller 2020-12-03T03:29:58.145200Z

anyways, feedback welcome

alexmiller 2020-12-03T03:31:36.146600Z

there are also apis to get as data, might be useful to have a version to print or spit the tree as edn instead of printing? dunno

dominicm 2020-12-03T08:04:39.147500Z

I could use edn output, then pipe into jet for manipulation.

jcf 2020-12-03T16:06:12.149300Z

Hey all. I'm clutching at straws here so apologies for the noise. πŸ™‚ Anyone tried installing deps today and noticed classpath issues like this:

Downloading: com/datomic/ion/0.9.48/ion-0.9.48.jar from datomic-cloud
Error building classpath. Could not find artifact com.datomic:ion:jar:0.9.48 in central (<https://repo1.maven.org/maven2/>)
I thought it was some silly Docker stuff I was doing but I'm seeing the same problem inside a GitHub action now. Given the line that says "Downloading" I'm confused as to why a classpath can't be built.

jcf 2020-12-04T08:36:14.197600Z

This user defaults to eu-west-2. I tried the suffix on the repo URL but no dice.

jcf 2020-12-04T08:36:54.198800Z

And massive thanks for your help on this, @alexmiller. :man-bowing:

alexmiller 2020-12-04T14:44:57.200200Z

can you try setting your default region creds to us-east-1?

alexmiller 2020-12-04T14:46:23.200400Z

either via the region in your credentials file or setting AWS_REGION

jcf 2020-12-04T15:38:35.200600Z

Coming right up! Thanks! πŸ™‚

jcf 2020-12-04T16:21:04.201100Z

@alexmiller I think I've found the right combination of permissions and Docker configuration to get things working! πŸ’₯ The IAM policy I shared previously should do the trick. There were two things I had to do to get Docker working: 1. Use COPY to add an AWS directory to the container at the beginning of the build; use of environment variables is frowned up for security reasons, and is hard to get right with enviroment: and env_file: not working at build time. If you want env vars at build time you need to add ARGs to your Dockerfile and then you can set args: within your build context. πŸ™‚ 2. Replace use of the new -P option and invoke clojure -Srepro -A:dev:test:etc -e 'nil'. I mount the same ~/.aws volume at runtime but could swap out new credentials if necessary (which could make sense if you want different access at build vs. runtime). I've got a running container with all the Datomic goodness available including connecting the SOCKS proxy up to a running system. I can connect Cider from Emacs and get all the code reloading goodness you'd expect. I've created a client and I can list databases in the Solo topology running on AWS. I have to say another massive thank you for all your help with this! Thank you! And merry Christmas! πŸŽ… πŸŽ„

alexmiller 2020-12-04T16:22:58.201300Z

well I'm glad it's working. I'm curious why you needed the alternate clojure command, seems like if those aliases are relevant you could use clojure -Srepro -A:dev:test:etc -P

jcf 2020-12-04T16:28:25.201500Z

I chalked the -P up to using a newer version of tools.deps on my host machine to what's in the most recent Docker image for Clojure. I might have just gotten the order of the arguments wrong in that case. 🀷

alexmiller 2020-12-04T16:29:43.201700Z

yeah, that version could be lagging

alexmiller 2020-12-04T16:29:56.201900Z

but if you're missing -P that's a good workaround

πŸ‘ 1
jcf 2020-12-03T16:06:52.149400Z

I started out creating a question here because I thought it was a problem with the Datomic Maven repo but I can download the JAR with aws s3 cp just fine. http://ask.datomic.com/index.php/546/could-not-find-artifact-com-datomic-ion-jar-0-9-48-in-central

jcf 2020-12-03T16:07:02.149700Z

This works:

aws s3 cp <s3://datomic-releases-1fc2183a/maven/releases/com/datomic/ion/0.9.48/ion-0.9.48.jar> .

jcf 2020-12-03T16:08:42.149900Z

$ clojure -h | head
Version: 1.10.1.739

jcf 2020-12-03T16:09:03.150100Z

It works on my machine. πŸ˜„

alexmiller 2020-12-03T16:09:19.150300Z

do you have AWS creds set?

jcf 2020-12-03T16:10:16.150500Z

On my machine, yep. Defaults and profiles. In the Docker container I had AWS_ACCESS_KEY_ID and secret exported at build time, but have since moved that so the creds are only there at runtime. Inside the GitHub Action I've not exported anything or configured AWS in any way.

jcf 2020-12-03T16:10:39.150700Z

Are you thinking my AWS creds are making things work on this host machine?

jcf 2020-12-03T16:10:59.150900Z

I read that for Maven repos on S3 there's some AWS API interaction required to get the region. I guess that could be failing.

alexmiller 2020-12-03T16:11:11.151100Z

yes, it needs to determine the bucket location

jcf 2020-12-03T16:11:37.151300Z

You can stick a ?region=... on the end of the :mvn/repo URL I think. I could try that.

jcf 2020-12-03T16:11:51.151500Z

I don't know which region the Datomic Cloud bucket is in but I should be able to find out.

alexmiller 2020-12-03T16:11:59.151700Z

it's us-east-1

jcf 2020-12-03T16:12:22.151900Z

I'll try that now. Thanks Mr. Miller. Uno momento.

jcf 2020-12-03T16:13:55.152100Z

Building a Docker container, and running a job (?) via GitHub Actions.

jcf 2020-12-03T16:14:44.152300Z

No joy with GitHub:

Downloading: com/datomic/ion/0.9.48/ion-0.9.48.jar from datomic-cloud
Downloading: joda-time/joda-time/2.10/joda-time-2.10.jar from central
Downloading: commons-codec/commons-codec/1.15/commons-codec-1.15.jar from central
Error building classpath. Could not find artifact com.datomic:ion:jar:0.9.48 in central (<https://repo1.maven.org/maven2/>)

jcf 2020-12-03T16:16:13.152500Z

Docker sits here for a few seconds and then continues on its way:

Downloading: com/datomic/ion/0.9.48/ion-0.9.48.pom from datomic-cloud
Downloading: com/datomic/ion/0.9.48/ion-0.9.48.jar from datomic-cloud
Downloading: tigris/tigris/0.1.2/tigris-0.1.2.jar from clojars
Downloading: javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar from central
Downloading: com/cognitect/aws/appsync/809.2.784.0/appsync-809.2.784.0.jar from central
Downloading: com/amazonaws/aws-java-sdk-s3/1.11.210/aws-java-sdk-s3-1.11.210.jar from central
Error building classpath. Could not find artifact com.datomic:ion:jar:0.9.48 in central (<https://repo1.maven.org/maven2/>)
ERROR: Service 'clojure' failed to build : The command '/bin/sh -c clojure -Srepro -P -A:dev:test:cider-clj' returned a non-zero code: 1

jcf 2020-12-03T16:16:27.152700Z

I'm not sure why tools.deps is downloading things twice.

jcf 2020-12-03T16:16:50.152900Z

Should there be two lines "Downloading" com.datomic/ion ?

alexmiller 2020-12-03T16:17:39.153100Z

yes, pom and jar

jcf 2020-12-03T16:17:54.153300Z

Ahh, that makes sense.

jcf 2020-12-03T16:18:06.153500Z

Hmm. I'm still stumped in that case. :thinking_face:

jcf 2020-12-03T16:25:36.154100Z

Okay, I can reproduce locally.

mv ~/.aws{,-ignore}
mv ~/.m2/repository/com/datomic/ion{,-ignore}
Then when I jack in I see the Ion dependency being downloaded and then the same error:
error in process sentinel: Could not start nREPL server: Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
DEPRECATED: Libs must be qualified, change compliment =&gt; compliment/compliment 
DEPRECATED: Libs must be qualified, change nrepl =&gt; nrepl/nrepl 
DEPRECATED: Libs must be qualified, change refactor-nrepl =&gt; refactor-nrepl/refactor-nrepl 
Downloading: com/datomic/ion/0.9.48/ion-0.9.48.pom from datomic-cloud
Downloading: org/clojure/clojure/maven-metadata.xml from datomic-cloud
Downloading: com/datomic/ion/0.9.48/ion-0.9.48.jar from datomic-cloud
Error building classpath. Could not find artifact com.datomic:ion:jar:0.9.48 in central (<https://repo1.maven.org/maven2/>)

jcf 2020-12-03T16:29:59.154400Z

Interestingly there's nothing in my ~/.m2/repository/com/datomic/ion/0.9.48 directory…

jcf 2020-12-03T16:30:37.154700Z

I can see two .part files show up momentarily, and then they disappear after I'm told classpath construction failed.

alexmiller 2020-12-03T16:32:57.154900Z

it has to do with the aws creds of whatever user you're using

alexmiller 2020-12-03T16:34:05.155100Z

it does not have iam access to s3 ops or something like that

jcf 2020-12-03T16:35:20.155300Z

So to pull down the Ion dependency I need to configure AWS and ensure I have at least some S3 permissions?

alexmiller 2020-12-03T16:40:07.155500Z

you need to be using aws user credentials that don't prevent s3 use for HeadObject, GetObject, and maybe GetBucketLocation

jcf 2020-12-03T16:41:53.155700Z

Okay, I'll create an IAM policy that grants that access. πŸ‘ I can test that pretty quickly with Docker. GitHub Actions will take a little longer. πŸ™‚

jcf 2020-12-03T16:42:12.155900Z

Dos momentos.

alexmiller 2020-12-03T16:42:21.156100Z

the objects you're going after definitely still exist and are public in the bucket, the issue here is around IAM on the accessing user

πŸ‘ 1
jcf 2020-12-03T17:26:44.156900Z

@alexmiller I see you've answered my question over on http://ask.datomic.com. I've added the following policy and I'm seeing the same error:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "",
            "Effect": "Allow",
            "Action": "s3:GetBucketLocation",
            "Resource": "arn:aws:s3:::*"
        },
        {
            "Sid": "",
            "Effect": "Allow",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::datomic-releases-1fc2183a/*"
        }
    ]
}
There is no HeadObject action as far as I can tell; you get that with GetObject. Is there something else I'm missing? I can't find anything in the Datomic Cloud or tools.deps docs otherwise I wouldn't be pestering you like this. Sorry!

jcf 2020-12-03T17:27:40.157100Z

jcf 2020-12-03T17:29:36.157500Z

alexmiller 2020-12-03T17:35:10.157900Z

sorry I'm not an IAM guru

alexmiller 2020-12-03T17:36:18.158100Z

is there some kind of simulator or something that can answer whether this user has access to some resource?

jcf 2020-12-03T17:36:49.158300Z

I've added the credentials to my local machine and I'm trying out the operations using the AWS CLI.

jcf 2020-12-03T17:37:05.158500Z

Copying the JAR worked. Just checking I can fetch the bucket location.

jcf 2020-12-03T17:38:04.158700Z

Okay, so I'm not allowed to get the bucket location. That's not surprising though as it's not my bucket. I shouldn't be able to grant myself permission to interact with buckets owned by other people.

jcf 2020-12-03T17:38:34.158900Z

$ aws --profile REDACTED s3api get-bucket-location --bucket datomic-releases-1fc2183a

An error occurred (AccessDenied) when calling the GetBucketLocation operation: Access Denied

jcf 2020-12-03T17:39:22.159100Z

$ aws --profile REDACTED s3 cp <s3://datomic-releases-1fc2183a/maven/releases/com/datomic/ion/0.9.48/ion-0.9.48.jar> .

download: <s3://datomic-releases-1fc2183a/maven/releases/com/datomic/ion/0.9.48/ion-0.9.48.jar> to ./ion-0.9.48.jar

seancorfield 2020-12-03T18:01:50.160200Z

@alexmiller Any further thoughts on TDEPS-174 and/or TDEPS-175? I'm finding more and more that those are obstacles to things we want to do at work 😞

alexmiller 2020-12-03T19:05:59.160300Z

this bucket has a policy that GetBucketLocation is open to *

alexmiller 2020-12-03T19:06:23.160500Z

you may be hitting something region related though - what's the default region for this user?

alexmiller 2020-12-03T19:06:55.160700Z

buckets are inherently region-specific

alexmiller 2020-12-03T19:07:41.160900Z

this is the case where adding the ?region=us-east-1 suffix to the url should help I think

alexmiller 2020-12-03T19:08:42.161200Z

haven't worked on it yet

borkdude 2020-12-03T20:00:58.163100Z

Why does clj download this long list of deps with an empty deps.edn? Among these is an AWS api lib. Why? I'll post this as a snippet.

borkdude 2020-12-03T20:01:39.163200Z

borkdude 2020-12-03T20:10:15.164700Z

When setting :mvn/local-repo "/tmp/mvn/foo" the list is even longer. I thought the tools jar was an uberjar that contained all clj needs

dominicm 2020-12-03T20:10:42.164800Z

@borkdude Is it possibly the deps in the system deps.edn?

borkdude 2020-12-03T20:11:43.165100Z

I guess so yes:

:aliases {
    :deps {:replace-deps {org.clojure/tools.deps.alpha {:mvn/version "0.9.833"}
                          org.slf4j/slf4j-nop {:mvn/version "1.7.25"}}
           :ns-default clojure.tools.cli.api}
    :test {:extra-paths ["test"]}
  }

borkdude 2020-12-03T20:12:11.165700Z

The question remains: why is there an AWS api lib among the deps of tools.deps.alpha. That feels not right.

Derek Passen 2020-12-03T20:13:35.166100Z

fetching from an s3 repo, maybe?

πŸ‘ 1
borkdude 2020-12-03T20:14:37.166300Z

Ah right, that must be it!

borkdude 2020-12-03T20:14:49.166400Z

borkdude 2020-12-03T20:18:39.167600Z

The tree looks great. But to get the deps tree of tools.deps I had to add it to the main deps, because you can't activate an alias. So running into the same problem that Sean ran into.

dominicm 2020-12-03T20:32:42.167700Z

@borkdude I don't fully understand why those aren't part of uberjar either though :)

alexmiller 2020-12-03T21:00:27.167900Z

the :deps alias doesn't use the uberjar

alexmiller 2020-12-03T21:02:36.169100Z

running -X:deps tree is in no way magical and doesn't use any parts of clj - it's just running a program that is in tools.deps.alpha library

alexmiller 2020-12-03T21:03:25.169500Z

the uberjar is used by clj to get the classpath of the program to run

alexmiller 2020-12-03T21:04:35.170100Z

@borkdude I'm a little confused by "But to get the deps tree ofΒ tools.depsΒ I had to add it to the main deps, because you can't activate an alias. So running into the same problem that Sean ran into."

alexmiller 2020-12-03T21:05:13.170600Z

or nvm, I think I am reading it properly now

borkdude 2020-12-03T21:06:24.172200Z

@alexmiller it's not magical, but the deps it downloads are probably already in the uberjar. but I get the point of not using that as that would be magical. unless :deps was by convention a built-in thing that always uses the tools jar.

alexmiller 2020-12-03T21:06:39.172500Z

correct

alexmiller 2020-12-03T21:07:00.173Z

it's intentionally not that because there is no way to add additional deps and then de-dupe across the uberjar

alexmiller 2020-12-03T21:07:11.173300Z

uberjars are inherently unfriendly to combination

borkdude 2020-12-03T21:07:30.173900Z

good point

alexmiller 2020-12-03T21:08:15.174700Z

uberjars are evil, but a useful evil if you keep them to yourself

alexmiller 2020-12-03T21:09:52.175400Z

anyways, I'm going to change -Stree to do the format above too, so you'll be able to do all the things you do now with deps

alexmiller 2020-12-03T21:10:38.176Z

and whenever we get to it, you should be able to use options to modify the -X:deps tree program too

alexmiller 2020-12-03T21:11:47.176500Z

one question I have is whether -Stree should show something like above or if it should be filtered to just the included libs like it does now

borkdude 2020-12-03T21:34:51.177200Z

filtering can always be done with grep

borkdude 2020-12-03T21:36:17.177400Z

$ clj -X:deps tree | grep -v "X "

alexmiller 2020-12-03T21:59:52.177800Z

I guess what I'm asking is would you prefer to usually see excluded or not?

seancorfield 2020-12-03T22:09:13.180500Z

(FWIW, I've spent a chunk of today moving us off the CLJ_CONFIG "hack" and we've decided to bite the bullet and generate our deps.edn files from a master template and a subproject template -- handling all the :override-deps directly ourselves... if the CLI / t.d.a ever supports an additional "shared project" deps.edn file, we'll switch back to that format... just got tired of dealing with tooling that doesn't honor CLJ_CONFIG and/or aliases 😞 )

seancorfield 2020-12-03T22:12:05.181200Z

Four hours of restructuring our "build" script etc and I can now run the new -X:deps tree on our subprojects πŸ™‚

seancorfield 2020-12-03T22:15:22.182Z

So, yeah, the new tree structure is very nice -- thanks @alexmiller -- I haven't yet seen a * case in any of our subprojects...

alexmiller 2020-12-03T22:16:05.182600Z

I changed that before I put it out, but you can check for the trailing :superseded tag

seancorfield 2020-12-03T22:17:00.183Z

Oh, I thought * indicated the newer selected version?

alexmiller 2020-12-03T22:17:11.183200Z

not in the release, no

borkdude 2020-12-03T22:17:48.183800Z

So you basically went the interdeps-like route?

seancorfield 2020-12-03T22:17:50.184Z

Ah, OK. I see some :older-version tags. Haven't seen a :superseded tag yet

seancorfield 2020-12-03T22:18:48.184100Z

There were things I didn't like about how interdeps worked so I did not go back and look at it when I rebuilt our stuff today.

alexmiller 2020-12-03T22:18:55.184500Z

are you still doing a flat list of deps?

borkdude 2020-12-03T22:19:17.184600Z

I figured you didn't want to take on some dep, that's why I added the -like suffix

alexmiller 2020-12-03T22:19:31.184900Z

if so, you'll never see it

seancorfield 2020-12-03T22:19:43.185Z

We ended up with &lt;subproject&gt;/&lt;subproject&gt;-deps.edn for the templates and a &lt;subproject&gt;/&lt;subproject&gt;-deps.md5 file for the checksums so we can regen on-demand automatically in our build script.

alexmiller 2020-12-03T22:20:43.185700Z

or if you're always doing some stuff to use a consistent set of transitive dep versions, same thing

seancorfield 2020-12-03T22:21:02.185800Z

The checksum for each subproject includes the checksum for the master file as well, so we regenerate any &lt;subproject&gt;/deps.edn file if either the master template or the subproject template has changed. We have not yet tackled the issue of transitive :local/root dependencies (we probably won't, unless it actually bites us).

seancorfield 2020-12-03T22:22:03.186400Z

Just run a full pass looking for :superseded and, yup, plenty are showing up. Nice!

borkdude 2020-12-03T22:22:05.186500Z

I'll probably roll my own solution for this too, like I did in the boot era, if this remains unsupported.

seancorfield 2020-12-03T22:22:27.186800Z

(mostly Jackson "of course")

☝️ 1
alexmiller 2020-12-03T22:23:17.187300Z

I mean, that is actually something to maybe look at given that Jackson version changes are (often) breaking

borkdude 2020-12-03T22:24:04.187500Z

Do you actually parse the EDN and merge yourself, or do you use simple string templating

seancorfield 2020-12-03T22:29:10.187800Z

Merge the EDN. I lift the :defaults aliases out of the master template and pull it's :override-deps out and then update the project template deps with those overrides.

borkdude 2020-12-03T22:30:14.188200Z

yeah, easy enough.

alexmiller 2020-12-03T22:35:44.188900Z

there's like a next level of potential analysis here to gather the set of versions seen

alexmiller 2020-12-03T22:37:36.189100Z

etc etc

seancorfield 2020-12-03T22:44:44.189800Z

Yeah, it looks like we unexpectedly have some lower level pieces of Jackson that aren't being explicitly overridden...

seancorfield 2020-12-03T22:47:16.190800Z

Here's partial output:

. com.fasterxml.jackson.dataformat/jackson-dataformat-smile 2.10.2 :newer-version
      . com.fasterxml.jackson.dataformat/jackson-dataformat-cbor 2.10.2 :newer-version
  X com.fasterxml.jackson.dataformat/jackson-dataformat-cbor 2.8.11 :superseded
    . com.fasterxml.jackson.dataformat/jackson-dataformat-cbor 2.8.11
    . com.fasterxml.jackson.dataformat/jackson-dataformat-smile 2.8.11
    X com.fasterxml.jackson.dataformat/jackson-dataformat-smile 2.9.6 :parent-omitted
    X com.fasterxml.jackson.dataformat/jackson-dataformat-cbor 2.9.6 :parent-omitted
  X com.fasterxml.jackson.dataformat/jackson-dataformat-smile 2.8.11 :superseded
I'm not sure how to interpret that @alexmiller?

seancorfield 2020-12-03T22:52:38.194300Z

These are a top-level dep in a :local/root dep of this project:

. com.fasterxml.jackson.dataformat/jackson-dataformat-cbor 2.8.11
    . com.fasterxml.jackson.dataformat/jackson-dataformat-smile 2.8.11
I guess we'll need to add it in some of our projects that only depend on other :local/root projects

alexmiller 2020-12-03T22:53:03.194700Z

the tags you'll see at the end are really an artifact of the order they're found so that's not super relevant, but can be relevant if the set of considered versions are substantially different

alexmiller 2020-12-03T22:54:09.195100Z

you probably aren't even use those sub parts of jackson anyways

seancorfield 2020-12-03T22:54:50.195600Z

Ah, OK. So nothing to worry about here because it picks the same version anyway?

alexmiller 2020-12-03T22:57:00.195800Z

prob not