Skip to content

`lein install` fails with zero git commits #860

frenchy64 opened this Issue Nov 21, 2012 · 6 comments

4 participants


Running lein install on a Leiningen project that has an initialised git repository with zero commits fails with an error like

/MY-PROJECT/.git/refs/heads/master (No such file or directory)
dyba commented Nov 25, 2012

I can't reproduce this error. I created a noir project using lein new noir simpleapp. I didn't make a single commit. I can successfully run the lein install command. Can you provide a slimmed down version of your application that shows the issue?


Did you try staging something?


Lein retrieves current HEAD commit to add it to the SCM information in pom.xml. The edge case with HEAD not resolving because there are no commits is probably not handled.


I can reproduce:

cd /tmp
λ /tmp/ lein new superlib
Generating a project called superlib based on the 'default' template.
To see other templates (app, lein plugin, etc), try `lein help new`.
λ /tmp/ cd superlib 
λ /tmp/superlib/ git init
Initialized empty Git repository in /private/tmp/superlib/.git/
λ /tmp/superlib/ master* git add src/
λ /tmp/superlib/ master* lein install
/private/tmp/superlib/.git/refs/heads/master (No such file or directory)

Here's what Leiningen does:

(defn- read-git-head
  "Reads the value of HEAD and returns a commit SHA1."
  (let [head (.trim (slurp (str (io/file git-dir "HEAD"))))]
    (if-let [ref-path (second (re-find #"ref: (\S+)" head))]
      (read-git-ref git-dir ref-path)

(defn- make-git-scm [git-dir]
    (let [origin (read-git-origin git-dir)
          head (read-git-head git-dir)
          urls (github-urls origin)]
       (and (:public-clone urls)
            [:connection (str "scm:git:" (:public-clone urls))])
       (and (:dev-clone urls)
            [:developerConnection (str "scm:git:" (:dev-clone urls))])
       [:tag head]
       [:url (:browse urls)]])
    (catch _)))

Not sure what a proper fix should look like. Checking if tag is nil and not including the information?


This is fixed in 80cf398

@technomancy technomancy closed this Dec 3, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.