Fork me on GitHub
#tools-deps
<
2021-02-22
>
murtaza5206:02:01

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)"}}

pavlosmelissinos06:02:13

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

hiredman06:02:36

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

hiredman06:02:15

Calling it with -Sdescribe will tell you which

hiredman06:02:18

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

Jakub Holý (HolyJak)17:02:28

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!

borkdude17:02:32

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

borkdude17:02:31

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

borkdude17:02:08

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

Jakub Holý (HolyJak)19:02:17

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

Jakub Holý (HolyJak)19:02:54

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

Alex Miller (Clojure team)19:02:18

yes, that's what I meant

Jakub Holý (HolyJak)18:02:27

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)? 🙏

borkdude19:02:45

master isn't a tag right?

Alex Miller (Clojure team)19:02:16

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

Alex Miller (Clojure team)19:02:05

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)

Alex Miller (Clojure team)19:02:52

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

borkdude19:02:54

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

borkdude19:02:20

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

Alex Miller (Clojure team)19:02:45

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

Alex Miller (Clojure team)19:02:09

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

Alex Miller (Clojure team)19:02:27

(he says, without confirming :)

cparen 3
borkdude19:02:30

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.

Alex Miller (Clojure team)19:02:14

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

borkdude19:02:53

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

Jakub Holý (HolyJak)19:02:20

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

{:git/url ""
                                                                          :sha "fake"
                                                                          :tag "v1"}
but still it does not do anything.

Alex Miller (Clojure team)19:02:23

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

Alex Miller (Clojure team)19:02:53

they are not pushed by default

Jakub Holý (HolyJak)19:02:12

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

Jakub Holý (HolyJak)19:02:11

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

Alex Miller (Clojure team)19:02:59

try it without :sha "fake"

Alex Miller (Clojure team)19:02:01

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

3
Jakub Holý (HolyJak)19:02:45

spot on! Thanks a lot!

Alex Miller (Clojure team)19:02:59

that seems like a bug, will fix it

seancorfield19:02:18

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