tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
greg 2021-06-30T15:30:48.414600Z

How to pass vector as one of args for -X ? Example:

(ns xml)

(defn merge-files
  "Merges given XML files. Options:
   :files Vector of filenames, required
   :output Filename for merge output, optional"
  [{:keys [files output]}]
  ...)
Assuming there is no aliases specified in deps.edn, how to call merge-files? The attempt below seems to be invalid:
clj -X xml.merge-files :files '["file1.xml" "file2.xml"]' :output "file3.xml"

alexmiller 2021-06-30T15:37:03.415Z

why do you say it is invalid?

alexmiller 2021-06-30T15:37:32.415400Z

you also likely need to single quote the last arg

alexmiller 2021-06-30T15:37:44.415700Z

clj -X xml.merge-files :files '["file1.xml" "file2.xml"]' :output '"file3.xml"'

alexmiller 2021-06-30T15:38:23.417Z

alternately, you can now pass a trailing map in the latest version

clj -X xml.merge-files '{:files ["file1.xml" "file2.xml"] :output "file3.xml"}'

greg 2021-06-30T15:42:01.417700Z

thanks, works now, kind of Actually previously I tried to pass the vector '[file1.xml file2.xml]' I'm having now another issue: `Unqualified function can't be resolved: xml.merge-files' The full call is like that

clojure -Sdeps '{:paths ["scripts"]}' -X xml.merge-files :files '["~/.m2/settings.xml" "/tmp/settings.xml"]' :output '"te.xml"'

greg 2021-06-30T15:47:16.418Z

scripts is just a directory holding xml.clj file xml.clj file defined internally (ns xml) and (defn merge-files) Is there anything else I need to do?

greg 2021-06-30T15:47:43.418200Z

Alright, I should call clj -X xml/merge-files instead of clj -X xml.merge-files

alexmiller 2021-06-30T15:56:20.418400Z

yes, sorry!

greg 2021-06-30T15:58:54.418600Z

no no, my fault, thanks for help 🙂

dpsutton 2021-06-30T22:08:02.420600Z

i've got a strange bug that i just cannot figure out. We build our release with a clojure cli based program. It has local-roots for a project that builds the actual uberjar, and it includes the paths :paths ["src" "resources"]. And for whatever reason, this resources path is not showing up on the classpath for my coworker when running this release script, but it is for everyone else

dpsutton 2021-06-30T22:09:07.421400Z

I got him to run clojure -e "(run! println (clojure.string/split (System/getProperty \"java.class.path\") #\":\"))" and saved his output and my output and the only difference (after adjusting paths from his workspace to mine) is

diff ~/projects/work/diffs/my.classpath ~/projects/work/diffs/his.classpath
3d2
< /Users/coworker/workspace/metabase/bin/build-mb/resources

dpsutton 2021-06-30T22:10:02.421600Z

and we are both on Clojure CLI version 1.10.3.855

alexmiller 2021-06-30T22:20:07.422300Z

did you -Sforce on both?

alexmiller 2021-06-30T22:22:35.422800Z

does the directory exist on both?

dpsutton 2021-06-30T22:22:36.423Z

no. and i wish i would have told him to try that. are the cache's transitively used like that?

dpsutton 2021-06-30T22:23:33.424200Z

yeah. dir exists, and the file it should find is there. it just seems to be a stale classpath. and i believe the resources addition was recent, so if there's a stale classpath around that would make sense. didn't think that it might use a cached one of a local root though.

alexmiller 2021-06-30T22:24:15.424800Z

changes in local dep deps.edn are not automatically picked up - you have to -Sforce to pick up those changes

dpsutton 2021-06-30T22:24:25.425Z

at both locations?

dpsutton 2021-06-30T22:24:35.425300Z

or just the dep or just the top level?

alexmiller 2021-06-30T22:24:41.425500Z

top level is where it matters

alexmiller 2021-06-30T22:24:48.425800Z

since it's that classpath you care about here

dpsutton 2021-06-30T22:25:09.426400Z

awesome. thanks. think he's in an interview but we'll try that. thank you very much as always

alexmiller 2021-06-30T22:25:31.426800Z

in the leaf local dep, any changes in deps.edn should make that project stale and recompute there in that project

alexmiller 2021-06-30T22:26:14.427300Z

but things that depend on it will not automatically detect that change

dpsutton 2021-06-30T22:26:49.427700Z

oh i see. so the root's cache includes the old classpath and it doesn't know to invalidate

alexmiller 2021-06-30T22:26:55.427900Z

yep

dpsutton 2021-06-30T22:27:03.428100Z

got a good model of it now. thanks

alexmiller 2021-06-30T22:28:14.429200Z

for the wrapper to know to check that file, it would have to understand the deps model, which would mean running Clojure code, which would negate the benefit of the cache :)

dpsutton 2021-06-30T22:28:58.430200Z

i guess the cache doesn't include a hash of the deps.edn files. i've never looked inside of cpcache really.

alexmiller 2021-06-30T22:29:05.430300Z

I do think it could remember this info in the cache though and use that to determine the set of files to check for staleness

alexmiller 2021-06-30T22:29:23.430700Z

there is a ticket for this, just has never been something I've gotten around to

dpsutton 2021-06-30T22:29:34.431Z

i'll go look and vote for your next pass through. thanks

dpsutton 2021-06-30T22:30:15.431300Z

i think this is it but it's pretty verbose: <https://ask.clojure.org/index.php/7860/classpath-caching-does-invalidate-local-manifests-changed?show=7860#q7860>

alexmiller 2021-06-30T22:30:31.431500Z

yeah, that's it

👍 1
alexmiller 2021-06-30T22:32:09.432100Z

the hash includes knowledge about the current project's deps.edn files, but not ones in the cp

2021-06-30T23:05:40.437400Z

we have a new build script at work, and with it I (and no one else, including the CI server) sometimes get weird errors when running the tests about the clojure.core.cache.wrapped namespace being missing. I changed the test runner to pop open a repl when it hit that error instead of exiting, and poked around and found that clojure.core.cache.wrapped had been added to *loaded-libs* but the namespace didn't actually exist, when I removed it from *loaded-libs* it loaded fine. That to me sounds like a concurrent code loading issue, and some digging and monkey patching of require to dump stacktraces when called off the main thread and I have provisionally tracked it down to https://github.com/clojure/tools.deps.alpha/blob/master/src/main/java/clojure/tools/deps/alpha/util/S3TransporterFactory.java#L48 , I have seen the s3 transport do this in the middle of my test run: call back into clojure, which causes core.async and a ton of other deps to load, which races with code running the tests.

2021-06-30T23:07:08.438300Z

is there some way to call calc-basis synchronously?

alexmiller 2021-06-30T23:11:50.438600Z

you can pass -Sthreads 1

alexmiller 2021-06-30T23:13:42.439700Z

that's one source of multithreading in the download process, but doesn't actually get to that thing in S3TransporterFactory

2021-06-30T23:14:45.440800Z

I guess I could require clojure.tools.deps.alpha.util.s3-transporter in our build script, which would no-op the transport factory requiring it

alexmiller 2021-06-30T23:14:59.441100Z

I'm not sure exactly what your setup is but the S3 stuff is used to build a classpath via tdeps, so not sure why it's in process with your tests? (should be separate process)

alexmiller 2021-06-30T23:15:38.441300Z

unless you're using tdeps programmatically

2021-06-30T23:15:46.441500Z

our build script is

alexmiller 2021-06-30T23:16:21.442Z

then yeah, I'd try to force the load earlier

alexmiller 2021-06-30T23:17:37.442400Z

I guess I could use the require lock in the background load

2021-06-30T23:18:38.443100Z

dunno that would help, the test code being loaded is using require without the lock

alexmiller 2021-06-30T23:19:03.443300Z

true

seancorfield 2021-06-30T23:20:32.444900Z

We don't need the S3 stuff -- is there some env setting that prevents t.d.a. from even trying to load it? Or is the fact that it's part of that Java class's initializer making that impossible?

alexmiller 2021-06-30T23:23:19.445700Z

it's such a pain in the ass given how it's all initialized (see https://github.com/clojure/tools.deps.alpha/blob/master/src/main/clojure/clojure/tools/deps/alpha/util/maven.clj#L166)

alexmiller 2021-06-30T23:24:39.446700Z

and there's a Named annotation on that class so ends in the META-INF in the jar etc

alexmiller 2021-06-30T23:25:02.447100Z

nothing like dependency injection frameworks to ruin everything good about dependency injection

alexmiller 2021-06-30T23:25:30.447800Z

it is intended to be tolerant of not finding the class (which is just a crutch for using it without compilation during dev)

alexmiller 2021-06-30T23:25:56.448800Z

so you could just delete the class out of the jar if you were feeling crazy :)

alexmiller 2021-06-30T23:26:08.449Z

or use it as a git / local dep

alexmiller 2021-06-30T23:27:05.449800Z

but if you want something better, file a TDEPS ticket and I'll think about it better in a week or two

2021-06-30T23:27:29.450700Z

it defeated me trying to to even find how it was initialized because I was grepping for 's3' not 'S3' 🙂

alexmiller 2021-06-30T23:28:24.452100Z

if only I could just hand an instance to the thing that was using it rather than gen'ing a class and passing a class name

seancorfield 2021-06-30T23:28:31.452200Z

Yeah, when I use t.d.a from source -- via the add-libs branch -- I get the warning about S3 not being found but works 🙂 so maybe we'll just change out dependency from a maven version to a git sha and just live with the warning about S3 Transport not being loaded 🙂

seancorfield 2021-06-30T23:30:55.452700Z

@hiredman I sent you the :git/url coords, to save you looking it up.