jlesquembre / clj-nix

Nix helpers for Clojure projects
https://jlesquembre.github.io/clj-nix/
Eclipse Public License 2.0
138 stars 19 forks source link

Getting `not a git repository` errors from `tools.build` #88

Closed kenranunderscore closed 11 months ago

kenranunderscore commented 11 months ago

Hi, we've recently upgraded our nixpkgs pin and also clj-nix to its latest commit. Let's take a mkCljBin call that looks somewhat like this:

pkgs.mkCljBin {
  name = "check-i18n";
  inherit version;
  projectSrc = pkgs.lib.ag.gitignoreSource ../../../../client;
  main-ns = "foobar-client.i18n.main";
  buildCommand = "clj -T:build check-i18n-uber";
}

This led to this:

check-i18n> Picked up JAVA_TOOL_OPTIONS: -Duser.home=/nix/store/73rhk940l9vvzkdjp9m54zkb7ap7qirp-clj-cache
check-i18n> Error building classpath. Cannot run program "git": error=2, No such file or directory
check-i18n> java.io.IOException: Cannot run program "git": error=2, No such file or directory

So I added buildInputs = [ pkgs.gitMinimal ]; to the expression above. Now I get the following error which I really don't understand:

check-i18n> unpacking sources
check-i18n> unpacking source archive /nix/store/in6nb0clb4p4q7kn046cvgqaxyymrrfa-client
check-i18n> source root is client
check-i18n> patching sources
check-i18n> updateAutotoolsGnuConfigScriptsPhase
check-i18n> configuring
check-i18n> no configure script, doing nothing
check-i18n> building
check-i18n> Picked up JAVA_TOOL_OPTIONS: -Duser.home=/nix/store/73rhk940l9vvzkdjp9m54zkb7ap7qirp-clj-cache
check-i18n> Error building classpath. Unable to get tags /nix/store/d7cbl6sshc9w2nkqxjwbpi6msm3y9hac-gitlibs-config-dir/https/github.com/clojure/tools.build
check-i18n> fatal: not a git repository: '/nix/store/d7cbl6sshc9w2nkqxjwbpi6msm3y9hac-gitlibs-config-dir/https/github.com/clojure/tools.build'

Do you have any idea what could be going wrong? I tried going back to the previous clj-nix commit that worked for us, but still get the same behavior, leading me to think that clj-nix is not the culprit, but I have no idea what else is. The tools.build version maybe?

kenranunderscore commented 11 months ago

Nevermind, it seems to have been the tools.build version begin slightly incompatible now after all! I was on v0.8.*, and upgrading to v0.9.5 fixed the issue.

jlesquembre commented 11 months ago

@kenranunderscore probably the issue is related to tools.gitlibs, in some cases invokes git to do some checks, but it'll fail since we don't have network access at build time.

Did it work with a previous clj-nix version? If your project is open source, I'd like to take a look, to be sure I didn't introduce a bug in clj-nix.

kenranunderscore commented 11 months ago

"It" worked with a previous version of clj-nix, but rolling back to that version didn't fix the problem, leading me to believe that it's something else in nixpkgs that triggered the problem. It's a work project and thus closed-source though, so I cannot share anything. I hope the ticket existing might help someone else, should they stumble over this.

Btw now that I've upgraded tools.build, I could remove git from the buildInputs again and it still works.

jlesquembre commented 11 months ago

@kenranunderscore thanks, let me know if you find any other issue.

BTW, in general, you don't want git in buildInputs. If tools.build invokes it, it's to do some checks against the upstream repository, and it will fail since there is no network access at Nix build time.