Fork me on GitHub

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

 "Execution error (FileNotFoundException) at (\n-X:test (No such file or directory)\n",
  :clojure.error/line -2,
  :clojure.error/cause "-X:test (No such file or directory)",
  :clojure.error/source "",
  :clojure.error/phase :execution},
    :message "-X:test (No such file or directory)",
    :at [ open0 "" -2]}],
  [[ open0 "" -2]
   [ open "" 195]
   [ <init> "" 138]
   [ <init> "" 93]
   [clojure.lang.Compiler loadFile "" 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 "" 137]
   [clojure.lang.Var applyTo "" 705]
   [clojure.main main "" 40]],
  :cause "-X:test (No such file or directory)"}}


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:

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


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


Calling it with -Sdescribe will tell you which


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!


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


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


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


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


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


This is one lib that can do it (based on rewrite-clj):

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

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


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

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


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