Skip to content

Binary cache substituter does not handle server errors gracefully #396

Closed

Description

@edolstra

E.g. if a NAR has disappeared from the server (as often happens with Hydra), it says:

*** Downloading ‘http://hydra.nixos.org/nar/0spf0rb3hp2nxx75nigzgxz1m9f5524b-nixos-manpages’ to ‘/nix/store/0spf0rb3hp2nxx75nigzgxz1m9f5524b-nixos-manpages’...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 410 Gone

bzip2: Compressed file ends unexpectedly;
        perhaps it is corrupted?  *Possible* reason follows.
bzip2: Inappropriate ioctl for device
        Input file = (stdin), output file = (stdout)

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

error: unexpected end-of-file

The bzip2 error is because we're piping curl directly into bzip2.

The error message should be improved. Also, for a 410 Gone error, we should just proceed as if we never got a .narinfo for this path from the server.

Activity

  1. Profpatsch commented on Jul 6, 2015

    @Profpatsch
    Member

    Still happens for 410 Gone errors.

  2. mbbx6spp commented on Jul 7, 2015

    @mbbx6spp
    Contributor

    Temporary workaround suggestion for those having issues after doing --upgrade recently:

    nixos-rebuild switch --fallback --upgrade

  3. rimmington commented on May 23, 2017

    @rimmington
    Contributor

    Ran into this today with an internal Hydra instance. I couldn't figure out how to get around it, so I just temporarily disabled the cache.

  4. domenkozar commented on Nov 29, 2017

    @domenkozar
    Member

    Interestingly --fallback doesn't work for me. --option build-fallback true did the trick.

  5. wizeman commented on Nov 29, 2017

    @wizeman
    Member

    @domenkozar: I ran into the same issue, see #807.
    Are you using import-from-derivation by any chance? It only happened to me for those type of derivations.

  6. domenkozar commented on Nov 29, 2017

    @domenkozar
    Member

    Yes, it was importing nixpkgs from nix store

  7. edolstra commented on Feb 9, 2018

    @edolstra
    MemberAuthor

    This works correctly in 2.0.

  8. copumpkin commented on Feb 9, 2018

    @copumpkin
    Member

    It sure does!

  9. deepfire commented on May 15, 2018

    @deepfire

    @edolstra, would it be considered a bug in Nix 2.0 if a 410 Gone leads to an instantiation failure?

  10. edolstra commented on May 16, 2018

    @edolstra
    MemberAuthor

    Instantiation or build failure? I guess it could only happen at instantiation time if you're importing from a derivation.

    At build time, it would be a bug if the build failed on a 410 without --fallback. (Probably we should always fall back on a 404 or 410, but that's not the current behaviour IIRC.)

  11. deepfire commented on May 28, 2018

    @deepfire

    @edolstra, we have managed to reproduce the build failure -- the relevant details captured in https://gist.github.com/cleverca22/2038f9abd1f9778e66b63fdf02d67054

    Michael clarified that Nix is /nix/store/r2mk4a50zddpi3f7h7m3pdyngp2saasr-nix-2.0/bin/nix, fetched from http://nixos.org/releases/nix/nix-2.0/nix-2.0.tar.xz, hashes as (7024d327314bf92c1d3e6cccd944929828a44b24093954036bfb0115a92f5a14, sha256, outputHashMode=flat)

  12. domenkozar commented on May 28, 2018

    @domenkozar
    Member

    Yeah temporary workaround would be to patch Hydra to return 404 instead of 410.

  13. deepfire commented on Jun 5, 2018

    @deepfire

    Replacing 410 with 404 (as per https://github.com/input-output-hk/iohk-ops/pull/348/files) didn't help:

    these paths will be fetched (0.02 MiB download, 0.02 MiB unpacked):
      /nix/store/adm406ixpvkcg3xvc2hz7vnqjzmgrr73-update-notifier-2.3.0.tgz
      /nix/store/cnlv1rncz2qv5qnl8xkwha93ydbn0c0y-ws-2.3.1.tgz
    copying path '/nix/store/adm406ixpvkcg3xvc2hz7vnqjzmgrr73-update-notifier-2.3.0.tgz' from 'https://hydra.iohk.io'...
    copying path '/nix/store/cnlv1rncz2qv5qnl8xkwha93ydbn0c0y-ws-2.3.1.tgz' from 'https://cache.nixos.org'...
    building '/nix/store/xi54xwnqkyrlibc1mgbin7v01y7wx78c-animate.css-3.5.2.tgz.drv'...
    building '/nix/store/9v16cc6qgmg06a609s5mcglv5qcnxivj-array-equal-1.0.0.tgz.drv'...
    file 'nar/adm406ixpvkcg3xvc2hz7vnqjzmgrr73-update-notifier-2.3.0.tgz' missing from binary cache
    
  14. domenkozar commented on Jun 6, 2018

    @domenkozar
    Member

    Ah that's a missing nar, not narinfo. I think hydra should return 404 for narinfo if nar is missing.

    (although Nix should handle such case gracefully)

  15. edolstra commented on Jun 6, 2018

    @edolstra
    MemberAuthor

    I added automatic fallback for 404/410 errors: 4ac4f67, 691b758. (That is, you don't have to specify --fallback anymore.)

  16. deepfire commented on Jun 7, 2018

    @deepfire

    @edolstra, do you find it appropriate to have a corresponding nix revision bump in Nixpkgs?

  17. added a commit that references this issue on Mar 8, 2026
    16df34b
  18. added a commit that references this issue on Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions