tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
murtaza52 2021-02-22T06:29:01.005400Z

hi, a colleague of mine is not able to get any aliases working for clj, clj repl works fine, this is the error report -

{:clojure.main/message
 "Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).\n-X:test (No such file or directory)\n",
 :clojure.main/triage
 {:clojure.error/class java.io.FileNotFoundException,
  :clojure.error/line -2,
  :clojure.error/cause "-X:test (No such file or directory)",
  :clojure.error/symbol java.io.FileInputStream/open0,
  :clojure.error/source "FileInputStream.java",
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type java.io.FileNotFoundException,
    :message "-X:test (No such file or directory)",
    :at [java.io.FileInputStream open0 "FileInputStream.java" -2]}],
  :trace
  [[java.io.FileInputStream open0 "FileInputStream.java" -2]
   [java.io.FileInputStream open "FileInputStream.java" 195]
   [java.io.FileInputStream <init> "FileInputStream.java" 138]
   [java.io.FileInputStream <init> "FileInputStream.java" 93]
   [clojure.lang.Compiler loadFile "Compiler.java" 7571]
   [clojure.main$load_script invokeStatic "main.clj" 475]
   [clojure.main$script_opt invokeStatic "main.clj" 535]
   [clojure.main$script_opt invoke "main.clj" 530]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :cause "-X:test (No such file or directory)"}}

2021-02-22T06:36:36.008Z

My guess is the clj your colleague has is either a old version without -X support, or is not the tools.deps clj script

2021-02-22T06:37:15.008800Z

Calling it with -Sdescribe will tell you which

2021-02-22T06:38:18.010700Z

If you get a similar looking error to the above then it is not the tools.deps clj script, otherwise you will get output that tells you the version of the script

pavlosmelissinos 2021-02-22T06:47:13.013400Z

1. First of all, run clj -Sdescribe and upgrade if you're using an old version of clojure 2. It seems like you're running the command in two lines:

clj
-X:test
Probably not related to the error but just use a single line 3. -X runs a function. Is test a function? If not, and the test alias has a :main-opts, you should be using the -M (main) flag instead: clj -M:test

Jakub Holý 2021-02-22T17:49:28.015500Z

Hello! How do I use :git-url with :tag ? The official docs > Optional key :tag is used only to indicate the semantics of the sha is not very clear to me. Can I require a particular branch, or master, without hardcoding a sha? Thank you!

borkdude 2021-02-22T17:52:32.016100Z

@holyjak :git/url (with the slash) and I think you should run -Sresolve-tags to fill in the SHA

borkdude 2021-02-22T17:53:31.016400Z

Oh, this is now called: -X:deps git-resolve-tags

borkdude 2021-02-22T17:54:08.016900Z

I wonder if this will preserve comments, etc in the deps.edn file :thinking_face:

Jakub Holý 2021-02-22T17:58:46.017Z

thank you!

alexmiller 2021-02-22T18:06:28.017300Z

It won’t

Jakub Holý 2021-02-22T18:30:27.018200Z

It does not do anything, I get "No unresolved tags found." So how can I point the dep to "master" (and possibly get :sha auto-updated)? 🙏

Jakub Holý 2021-02-22T19:22:17.018300Z

I am sorry, was that a response to me? What won't what?

Jakub Holý 2021-02-22T19:22:54.018500Z

Ah, you meant that comments will not be preserved in the file.

alexmiller 2021-02-22T19:27:18.018700Z

yes, that's what I meant

borkdude 2021-02-22T19:27:45.019Z

master isn't a tag right?

alexmiller 2021-02-22T19:29:57.020300Z

correct, it's a branch

alexmiller 2021-02-22T19:30:16.020700Z

you're basically fighting what's provided now (which is intentionally narrowly scoped)

alexmiller 2021-02-22T19:33:05.021900Z

it would not be that hard to make something that updated the deps.edn to use the latest sha tracking a branch (tools.gitlibs in fact supports resolution of any rev, including branches)

alexmiller 2021-02-22T19:33:52.022500Z

I believe there is now a lib to update a deps.edn while preserving comments etc as well

borkdude 2021-02-22T19:33:54.022700Z

There is nothing which can't be fixed with a lil' scripting and templating

borkdude 2021-02-22T19:34:20.023Z

This is one lib that can do it (based on rewrite-clj): https://github.com/borkdude/rewrite-edn

alexmiller 2021-02-22T19:34:45.023800Z

yeah, that + tools.gitlibs is about 95% of what you need

alexmiller 2021-02-22T19:35:09.024600Z

you could add a :branch to the git coord, it will just be ignored by tools.deps

alexmiller 2021-02-22T19:35:27.025200Z

(he says, without confirming :)

1
borkdude 2021-02-22T19:35:30.025500Z

The approach that we are taking at work is having a deps.template.edn which we manipulate using a script which produces the final deps.edn. So comments are only preserved in the template, the deps.edn itself is just a pretty printed thing. You could just do this using pure git and no tools.deps even.

alexmiller 2021-02-22T19:36:14.026100Z

using tools.gitlibs will benefit you as it will cache the git dir and working tree shas in the same place and way as you'll get using them through tools.deps/clj

borkdude 2021-02-22T19:36:53.027Z

Getting the latest SHA doesn't require you to fetch the whole tree I think?

alexmiller 2021-02-22T19:37:04.027300Z

it won't

Jakub Holý 2021-02-22T19:37:20.028Z

I see, so branches do not work. I have pushed a tag, v1, and tried

{:git/url "<https://github.com/holyjak/fulcro-troubleshooting>"
                                                                          :sha "fake"
                                                                          :tag "v1"}
but still it does not do anything.

alexmiller 2021-02-22T19:37:23.028200Z

you can answer that from the git object dir, which is maintained independently from the sha working trees

alexmiller 2021-02-22T19:37:45.028500Z

did you push tags?

alexmiller 2021-02-22T19:37:53.028700Z

they are not pushed by default

Jakub Holý 2021-02-22T19:38:12.028900Z

yes, I did, and can see it in GH.

Jakub Holý 2021-02-22T19:39:11.029300Z

hm, maybe I should check if I have latest CLI ...

alexmiller 2021-02-22T19:39:59.029600Z

try it without :sha "fake"

alexmiller 2021-02-22T19:42:01.030200Z

I think it may not resolve the tag if it has a sha

1✅
Jakub Holý 2021-02-22T19:45:45.030400Z

spot on! Thanks a lot!

seancorfield 2021-02-22T19:46:54.031100Z

@holyjak FYI, this shows how to resolve master to a SHA: https://github.com/seancorfield/dot-clojure/blob/develop/deps.edn#L207-L211

1❤️
alexmiller 2021-02-22T19:46:59.031500Z

that seems like a bug, will fix it

seancorfield 2021-02-22T19:47:18.032Z

(if you ignore the add-libs aspect of it -- I'm just talking about the gitlibs part)