-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fetchGit fails with a not very helpful error message when fetching a revision not in the remote's HEAD #2431
Comments
This is a problem with Git in general with or without |
Right, I was a bit thrown off by the error message and thought that the cached git repo was corrupted, so I tried to delete it twice, to no avail. A hint in the error message of |
Or a warning saying 'you have provided no |
fetchGit
triggers fatal: not a tree object
error on non-master revision
People run into this problem. Example. Why not fetch the whole thing by default? Fetching nixpkgs was super slow on my machine despite this optimization, so my guess is that it's even better to just fetch the whole repo as a default, or otherwise as a fallback. I remember reading somewhere that github prefers whole checkouts because a dumb bulk operation is cheaper than a "smart" checkout with lots of random I/O. I suppose that's what I was seeing. Can we make this work by default? |
|
Perhaps we could have a default without surprises and an optimized one based on the |
I don't think there are any surprises here because this is simply how Git works. It doesn't in general support fetching
Fetching the entire repository is potentially much more expensive. For example, the Chromium repository reportedly has 500,000 refs. (https://opensource.googleblog.com/2018/05/introducing-git-protocol-version-2.html) |
Yes, this is not surprising to someone who is intimately familiar with git's inner workings, but that doesn't make it unsurprising to most people. I see two scenario's: A novice user learns about The other scenario is where someone does indeed fetch from a huge repository (refs or commits) and is not aware of the In my view, it's better to solve the first scenario than to solve the second.
The only reason I can think of to solve only the second scenario is
And that can be solved by looking at the number of refs and ratio of
Does this address all concerns? |
To me not specifying a BTW in the case of GitHub, it's probably better to use |
- unstable channels seems to be unstable => using runAsRoot causes problem with "darwin" instead of "linux" => switching to nixos-18.09 => only has jdk10 - fetchGit has it's issues NixOS/nix#2431 => maybe prefer fetchTarball
I think it's fine to expect users to specify |
The However, I was just trying to set it up on a new macOS again and I hit a bunch of issues. Can someone who understands this well, clean up these documentations, please? The https://nixos.wiki/wiki/FAQ/Pinning_Nixpkgs page does not say anything about The I would think the I'm trying to pin in my I'm just getting this error on
My
My
As mentioned above
However the
|
This is how I imagine a channel pinning guide: Pinning to a channelThe latest recommendation I could find proposes to use the To construct the URL for the
Github allows getting a Substituting the commit hash from the previous command into the gihub archive
Since neither of the hashes communicate what channel did they represent, As a result, your
Channel builds fail regularly, so you might want to pin them to a version The beginning of the Nixpkgs manual / Contributors Guide You can page back manually to find the latest passing build. If you click on Alternatively you can find the commit hash of the latest successful build more The 1st - Channel - column there links you to a directory, which contains
|
I also came up with an approach to combine the stable and the unstable channels, to minimize the amount of dependencies downloaded and to maximize the amount of binary cache used. Assuming a new package is only available in the unstable channel, BUT
I have no idea how good this solution is, but it seems to work... |
Observe that git needs the ref attribute as well (NixOS/nix#2431) and that the url ends on nixpkgs-channels not on nixpkgs/ (https://nixos.wiki/wiki/FAQ/Pinning_Nixpkgs)
I've updated the https://nixos.wiki/wiki/FAQ/Pinning_Nixpkgs page to include the |
@onetom Although I appreciate your effort to document pinning, it does not solve the unhelpful error message. It is not a solution to this issue, because even if it is documented everywhere, someone will forget to add the I agree with bgamari:
A reminder why it's not helpful, quoting sgraf812:
|
Seems like fetchGit doesn't necessarily fetch entire repos or filter by remote refs or something like it. That means it might not find revisions specified without a ref to go with it. NixOS/nix#2431
I found this pretty surprising, despite being pretty familiar with both nix and git. It almost seems like the |
To add to this and request it's revisited or prioritized, I just made a nix build for my team. Their first nix experience was this error after hearing about how "works on my machine could become a thing of the past" 😄 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/builtins-fetchgit-error-not-a-tree-object/6954/2 |
So it seems there are two ways to go forward as a default
Either way, fetching the whole repository should be an option because sometimes one has only a |
A good example that even experienced Nix users get stuck: https://twitter.com/ProgrammerDude/status/1275375411631927297 |
@edolstra I disagree. Let's take import-cargo as an example where we can only specify Recently I wanted to replace a |
I'll chime in again with my slight modification on the latter of: "not setting ref clones the whole repository but gives a warning" That would be kind of annoying in the case of archived checkouts in stack.yaml you linked though @domenkozar, so I'd say there should be a flag to disable that warning so that consumers like haskell.nix could disable it. |
…revision can't be checked out A common pitfall when using e.g. `builtins.fetchGit` is the `fatal: not a tree object`-error when trying to fetch a revision of a git-repository that isn't on the `master` branch and no `ref` is specified. In order to make clear what's the problem, I added a simple check whether the revision in question exists and if it doesn't a more meaningful error-message is displayed: ``` nix-repl> builtins.fetchGit { url = "https://github.com/owner/myrepo"; rev = "<commit not on master>"; } moderror: --- Error ------------------------------------------------------------------------------------------------ nix Cannot find git-revision in '<commit not on master>' of repo 'https://github.com/owner/myrepo' on ref 'master'! ``` Closes NixOS#2431
…revision can't be checked out A common pitfall when using e.g. `builtins.fetchGit` is the `fatal: not a tree object`-error when trying to fetch a revision of a git-repository that isn't on the `master` branch and no `ref` is specified. In order to make clear what's the problem, I added a simple check whether the revision in question exists and if it doesn't a more meaningful error-message is displayed: ``` nix-repl> builtins.fetchGit { url = "https://github.com/owner/myrepo"; rev = "<commit not on master>"; } moderror: --- Error ------------------------------------------------------------------------------------------------ nix Cannot find git-revision in '<commit not on master>' of repo 'https://github.com/owner/myrepo' on ref 'master'! ``` Closes NixOS#2431
…revision can't be checked out A common pitfall when using e.g. `builtins.fetchGit` is the `fatal: not a tree object`-error when trying to fetch a revision of a git-repository that isn't on the `master` branch and no `ref` is specified. In order to make clear what's the problem, I added a simple check whether the revision in question exists and if it doesn't a more meaningful error-message is displayed: ``` nix-repl> builtins.fetchGit { url = "https://github.com/owner/myrepo"; rev = "<commit not on master>"; } moderror: --- Error ------------------------------------------------------------------------------------------------ nix Cannot find git-revision in '<commit not on master>' of repo 'https://github.com/owner/myrepo' on ref 'master'! ``` Closes NixOS#2431
…revision can't be checked out A common pitfall when using e.g. `builtins.fetchGit` is the `fatal: not a tree object`-error when trying to fetch a revision of a git-repository that isn't on the `master` branch and no `ref` is specified. In order to make clear what's the problem, I added a simple check whether the revision in question exists and if it doesn't a more meaningful error-message is displayed: ``` nix-repl> builtins.fetchGit { url = "https://github.com/owner/myrepo"; rev = "<commit not on master>"; } moderror: --- Error ------------------------------------------------------------------------------------------------ nix Cannot find git-revision in '<commit not on master>' of repo 'https://github.com/owner/myrepo' on ref 'master'! ``` Closes NixOS#2431
…revision can't be checked out A common pitfall when using e.g. `builtins.fetchGit` is the `fatal: not a tree object`-error when trying to fetch a revision of a git-repository that isn't on the `master` branch and no `ref` is specified. In order to make clear what's the problem, I added a simple check whether the revision in question exists and if it doesn't a more meaningful error-message is displayed: ``` nix-repl> builtins.fetchGit { url = "https://github.com/owner/myrepo"; rev = "<commit not on master>"; } moderror: --- Error ------------------------------------------------------------------------------------------------ nix Cannot find git-revision in '<commit not on master>' of repo 'https://github.com/owner/myrepo' on ref 'master'! ``` Closes NixOS#2431
…revision can't be checked out A common pitfall when using e.g. `builtins.fetchGit` is the `fatal: not a tree object`-error when trying to fetch a revision of a git-repository that isn't on the `master` branch and no `ref` is specified. In order to make clear what's the problem, I added a simple check whether the revision in question exists and if it doesn't a more meaningful error-message is displayed: ``` nix-repl> builtins.fetchGit { url = "https://github.com/owner/myrepo"; rev = "<commit not on master>"; } moderror: --- Error -------------------------------------------------------------------- nix Cannot find Git revision 'bf1cc5c648e6aed7360448a3745bb2fe4fbbf0e9' in ref 'master' of repository 'https://gitlab.com/Ma27/nvim.nix'! Please make sure that the rev exists on the ref you've specified or add allRefs = true; to fetchGit. ``` Closes NixOS#2431
When supplying a url to nix-shell: nix-shell https://github/tweag/nickel/archive/master.tar.gz It does not attempt to load the shell.nix file contained in the tarball, instead only loading default.nix, which fails if it doesn't provide a viable shell. I would expect the behavior to be consistent with launching from the base of a repository, namely, load shell.nix if it exists, default.nix otherwise. (see divnix/digga@e2172c8)
I just found this issue by googling the error and immediately realised that this indeed a rather unhelpful error message. |
What error-message are you talking about? The issue described in here got fixed almost three years ago. I'd suggest to file a new issue rather than necro-bumping this thread and if it's actually related, then please cross-ref this issue there. |
Rather than trying to hijack #1923 any further, I instead open a new issue here.
I was trying to use the new (as of Nix 2) way of pinning nixpkgs, but it doesn't work for the at the time of this writing most recent
nixos-18.03
commit 01f5e794913a18494642b5f237bd76c054339d61:The problem here is mostly the
fatal: not a tree object
error. I suspect this is due tofetchGit
cloning with--depth 1
or taking some other shortcut, which only considersmaster
(in this casenixos-unstable
) commits. 01f5e794913a18494642b5f237bd76c054339d61 isn't an ancestor of master, so it will not be fetched, hence the error.Or maybe it's some other reason altogether.
Anyway, my current workaround is to useOr even by specifyingfetchTarball
instead.ref = "nixos-18.03";
as in #1923. I think this would be worth adding to the manuel entry.The text was updated successfully, but these errors were encountered: