Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I get "Did not find commit for refs/heads/master" when running ob init #1109

Open
ninjalf2 opened this issue Jan 29, 2025 · 5 comments
Open

Comments

@ninjalf2
Copy link

When I run ob init I get the following error message:

lasse@eniac:~/src/obelisk$ ob init
Did not find commit for refs/heads/master
Failure for git remote https://github.com/obsidiansystems/obelisk.git
✖ Setting up obelisk

I have tried installing both using the method mentioned in the README (nix-env) and using a flake, which is the method I would prefer.
I run my flake using nix develop --impure and I get dropped correctly into the devShell with ob available, but ob init fails.

My flake looks like this:

{
  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
    obelisk = {
      url = "github:obsidiansystems/obelisk";
      flake = false;
    };
    flake-utils.url = "github:numtide/flake-utils";
  };


  nixConfig = {
    binaryCaches = [ "https://nixcache.reflex-frp.org" ];
    binaryCachePublicKeys = [ "ryantrinkle.com-1:JJiAKaRv9mWgpVAz8dwewnZe0AzzEAzPkagE9SP5NWI=" ];

    extra-substituters = [ "https://nixcache.reflex-frp.org" ];
    extra-trusted-public-keys = [ "ryantrinkle.com-1:JJiAKaRv9mWgpVAz8dwewnZe0AzzEAzPkagE9SP5NWI=" ];
  };

  outputs = inputs: inputs.flake-utils.lib.eachDefaultSystem (system:
    let
      pkgs = import inputs.nixpkgs { inherit system; };
      obelisk = pkgs.callPackage inputs.obelisk {
        inherit system;
        terms.security.acme.acceptTerms = true;
      };
    in {
      inherit obelisk;
      devShells.default = pkgs.mkShell {
        nativeBuildInputs = [
          obelisk.command
        ];
      };
    });
}

I am on NixOS 24.11.

@alexfmpe
Copy link
Collaborator

alexfmpe commented Jan 30, 2025

What's the output of ob init -v ?
I suspect your nix develop shell is missing git or some nix-prefetch-* util.

You could try adding pkgs.git pkgs.nix-prefetch-git pkgs.nix to nativeBuildInputs. However, it seems to me the "Failure for git remote" message you're seeing has long been removed:

gitGetCommitBranch
:: MonadObelisk m => GitUri -> Maybe Text -> m (Text, CommitId)
gitGetCommitBranch uri mbranch = withExitFailMessage ("Failure for git remote " <> uriMsg) $ do

It's definitely not present on v1.1.0.0 which is well over a year old.

Not sure how you're roping in an old ob. Your flake input doesn't seem to point to any branch so exactly what is it using and how does it determine it?

If all else fails, bootstrap from a local checkout

$ cd obelisk
$ nix-build -A command
<output-nix-store-path>
$ cd directory-where-you-ob-init
$ <output-nix-store-path>/bin/ob init -v

@ninjalf2
Copy link
Author

lasse@eniac:~/src/obelisk$ ob init -v
Starting Obelisk </nix/store/5qhw99ipn683vik513frrqraz8c3p07j-obelisk-command-0.9.0.1/bin/.ob-wrapped> args=["init","-v"] logging-level=Debug
Cloning obelisk into /tmp/nix-shell.DDeNLc/ob-init-cf5e829a129ad7f5/.obelisk/impl and repacking using itself
Creating process: /nix/store/p340wmmzgg9aw2lm9g9jxmjdwdp2xk79-git-minimal-2.37.2/bin/git ls-remote --exit-code --symref $'https://github.com/obsidiansystems/obelisk.git' refs/heads/master
git ls-remote maps: (fromList [],fromList [])
Did not find commit for refs/heads/master
Failure for git remote https://github.com/obsidiansystems/obelisk.git
✖ Setting up obelisk

Yeah it does seem like I am using an old version..
I don't know how because I get the exact same result if I change my flake input to

obelisk = {
  url = "github:obsidiansystems/obelisk?ref=master";
  flake = fa1lse;
};

If all else fails, bootstrap from a local checkout

If I run the following commands I still end up with version 0.9.0.1

cd /tmp
git clone https://github.com/obsidiansystems/obelisk.git
cd obelisk
nix-build -A command # gives me /nix/store/5qhw99ipn683vik513frrqraz8c3p07j-obelisk-command-0.9.0.1
mkdir emptydir
cd emptydir
/nix/store/5qhw99ipn683vik513frrqraz8c3p07j-obelisk-command-0.9.0.1/bin/ob init -v

And the output of the last command is again

Starting Obelisk </nix/store/5qhw99ipn683vik513frrqraz8c3p07j-obelisk-command-0.9.0.1/bin/.ob-wrapped> args=["init","-v"] logging-level=Debug
Cloning obelisk into /tmp/ob-init-82fcf17430a97793/.obelisk/impl and repacking using itself
Creating process: /nix/store/p340wmmzgg9aw2lm9g9jxmjdwdp2xk79-git-minimal-2.37.2/bin/git ls-remote --exit-code --symref $'https://github.com/obsidiansystems/obelisk.git' refs/heads/master
git ls-remote maps: (fromList [],fromList [])
Did not find commit for refs/heads/master
Failure for git remote https://github.com/obsidiansystems/obelisk.git
✖ Setting up obelisk

I am still somewhat of a Nix newbie, so I might very well be doing something wrong.

@alexfmpe
Copy link
Collaborator

alexfmpe commented Jan 30, 2025

I don't know how because I get the exact same result if I change my flake input to

I don't know much about flakes, but maybe your flake.lock file or whatsitcalled ended up pinning an old master at some point and it never got updated?
Personally I never specify direct dependencies without a specific revision to avoid "do what I mean" problems

If I run the following commands I still end up with version 0.9.0.1

Same. However, that's 0.9.0.1 of obelisk-command. The github releases are for obelisk as a whole.
I get the exact same path: /nix/store/5qhw99ipn683vik513frrqraz8c3p07j-obelisk-command-0.9.0.1.
However, .../bin/ob init -v works and so does your .../bin/.ob-wrapped whatever that is.

Starting Obelisk </nix/store/k14z0jg8i9zvjn7m9sdz3wpczwbwj5k7-obelisk-command-0.9.0.1/bin/.ob-wrapped> args=["init","-v"] logging-level=Debug
Cloning obelisk into /tmp/ob-init-5e903db45be4ae2e/.obelisk/impl and repacking using itself
Creating process: /nix/store/p340wmmzgg9aw2lm9g9jxmjdwdp2xk79-git-minimal-2.37.2/bin/git ls-remote --exit-code --symref $'https://github.com/obsidiansystems/obelisk.git' refs/heads/master
git ls-remote maps: (fromList [],fromList [(GitRef_Branch "master","135bfd7422b856c146b5cd5dacfe584f0621825e")])
Latest commit in branch master from remote repo https://github.com/obsidiansystems/obelisk.git is 135bfd7422b856c146b5cd5dacfe584f0621825e

Not quite sure how that happens. Maybe you're calling the right ob, but it tries to handoff to what it thinks is the one on master but ends up getting an old version instead?

Let's see what the git ls-remote from your logs does if called directly. Over here it agrees with my local checkout

$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.

$ git rev-parse HEAD
135bfd7422b856c146b5cd5dacfe584f0621825e

$ git ls-remote --exit-code --symref $'https://github.com/obsidiansystems/obelisk.git' refs/heads/master
135bfd7422b856c146b5cd5dacfe584f0621825e	refs/heads/master

@ninjalf2
Copy link
Author

Thanks for helping out.

I get the same results as your git commands. 135bfd7 everywhere.

However, I noticed that the directories being created in this step
Cloning obelisk into /tmp/nix-shell.DDeNLc/ob-init-cf5e829a129ad7f5/.obelisk/impl
are always non-existent.
And the command fails instantly; it is not cloning anything.

Do you have stuff in the directory it says it clones to?

@alexfmpe
Copy link
Collaborator

alexfmpe commented Jan 31, 2025

However, it seems to me the "Failure for git remote" message you're seeing has long been removed:

I spoke too soon, it was just factored out into nix-thunk and cli-git
https://github.com/obsidiansystems/nix-thunk/blob/4b70b0ba007b4055491789cd7e15330b193ed380/src/Nix/Thunk/Internal.hs#L1609-L1610
So that was a red herring and your ob itself seems the right version.

are always non-existent.

IIRC all this use of temp dirs is bracketed so that they're cleaned up at the end or failure.

I get the same results as your git commands. 135bfd7 everywhere.

What if you call git inside your flake shell? And what if you call the command from the logs
/nix/store/p340wmmzgg9aw2lm9g9jxmjdwdp2xk79-git-minimal-2.37.2/bin/git ls-remote --exit-code --symref $'https://github.com/obsidiansystems/obelisk.git' refs/heads/master
inside/outside the nix shell ?

I'm suspecting something goes sideways with your git inside nix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants