Flake update or build resulting in: "Failed to open/read local data from file/application (26)"

This is a weird one.

When I try to run nix flake update nixpkgs I get the following error:

$ nix flake update nixpkgs
warning: error: unable to download 'https://api.github.com/repos/nixos/nixpkgs/commits/nixos-unstable-small': Failed to open/read local data from file/application (26); retrying in 339 ms
warning: error: unable to download 'https://github.com/nixos/nixpkgs/archive/6c33d760f16f52ffc0dd8538b9239808d96ec699.tar.gz': Failed to open/read local data from file/application (26); retrying in 270 ms
warning: error: unable to download 'https://github.com/nixos/nixpkgs/archive/6c33d760f16f52ffc0dd8538b9239808d96ec699.tar.gz': HTTP error 302 () (curl error: Failed to open/read local data from file/application)

       response body:

       ; retrying in 678 ms
warning: error: unable to download 'https://github.com/nixos/nixpkgs/archive/6c33d760f16f52ffc0dd8538b9239808d96ec699.tar.gz': HTTP error 302 () (curl error: Failed to open/read local data from file/application)

       response body:

       ; retrying in 1136 ms
warning: error: unable to download 'https://github.com/nixos/nixpkgs/archive/6c33d760f16f52ffc0dd8538b9239808d96ec699.tar.gz': HTTP error 302 () (curl error: Failed to open/read local data from file/application)

       response body:

       ; retrying in 2423 ms
error:
       … while updating the lock file of flake 'git+file:///Users/daniel/.config/nixpkgs?ref=refs/heads/master&rev=e8db349c81d6d6eb35455a72eaae72bce38498c4'

       … while updating the flake input 'nixpkgs'

       … while fetching the input 'github:nixos/nixpkgs/nixos-unstable-small'

       error: unable to download 'https://github.com/nixos/nixpkgs/archive/6c33d760f16f52ffc0dd8538b9239808d96ec699.tar.gz': HTTP error 302 () (curl error: Failed to open/read local data from file/application)

       response body:


This happens locally (where I have to confess that I use lix) and on one of my CI servers, where I use plain nix:

$ nix --version
nix (Nix) 2.24.10

CI server output looks like this (running nix flake update):

warning: error: unable to download 'https://api.github.com/repos/ryantm/agenix/commits/HEAD': Failed to open/read local data from file/application (26); retrying in 254 ms
unpacking 'github:ryantm/agenix/f6291c5935fdc4e0bef208cfc0dcab7e3f7a1c41' into the Git cache...
warning: error: unable to download 'https://github.com/ryantm/agenix/archive/f6291c5935fdc4e0bef208cfc0dcab7e3f7a1c41.tar.gz': Failed to open/read local data from file/application (26); retrying in 252 ms
warning: error: unable to download 'https://github.com/ryantm/agenix/archive/f6291c5935fdc4e0bef208cfc0dcab7e3f7a1c41.tar.gz': HTTP error 302 (curl error: Failed to open/read local data from file/application); retrying in 615 ms
warning: error: unable to download 'https://github.com/ryantm/agenix/archive/f6291c5935fdc4e0bef208cfc0dcab7e3f7a1c41.tar.gz': HTTP error 302 (curl error: Failed to open/read local data from file/application); retrying in 1250 ms
warning: error: unable to download 'https://github.com/ryantm/agenix/archive/f6291c5935fdc4e0bef208cfc0dcab7e3f7a1c41.tar.gz': HTTP error 302 (curl error: Failed to open/read local data from file/application); retrying in 2227 ms
error:
       … while updating the lock file of flake 'git+file:///workspace/***/dotfiles?ref=refs/heads/master&rev=e8db349c81d6d6eb35455a72eaae72bce38498c4&shallow=1'
       … while updating the flake input 'agenix'
       … while fetching the input 'github:ryantm/agenix'
       error: Failed to open archive (Source threw exception: error: unable to download 'https://github.com/ryantm/agenix/archive/f6291c5935fdc4e0bef208cfc0dcab7e3f7a1c41.tar.gz': HTTP error 302 (curl error: Failed to open/read local data from file/application))

Since this happens locally and on a Hetzner server (and using lix and nix) I’m at a complete loss.

This seems to only be an issue with GitHub inputs.

The error message (HTTP error 302) raises more questions than it answers, to be honest.

Anyone know what’s going on here?

Edit

This is something that must’ve broken very recently (on nixos-unstable-small), as an older generation works just fine.

Sadly on some machines, the older generation was already garbage-collected. Not sure what to do in that case …

7 Likes

If you use netrc then git fails to fetch via curl 8.11.0 · Issue #356114 · NixOS/nixpkgs · GitHub might be the related issue.

8 Likes

Thanks @Shawn8901!! This was the pointer I needed. I use netrc because of an attic cache, and (temporarily) disabling the config line in my nix config for netrc allowed me to use flakes again (minus pulling from my personal cache, but I can wait until curl: backport netrc regression fix by Scrumplex · Pull Request #356133 · NixOS/nixpkgs · GitHub makes it into nixpkgs-unstable)

2 Likes

Thanks! Looks like it is indeed related to that.

I found the issue before, but thought it was unrelated because the error message didn’t match.

Weird that this made it all the way into the 24.11 branch without being caught.

1 Like

Link to track whether above PR #356133 with the fix has landed in a channel: Nixpkgs-tracker

4 Likes

Has anyone had any luck using an overlay to be able to rebuild their system?

There are two different overlays I’ve found and tried that didn’t seem to have any effect despite seeing that nix got recompiled the first time:

Version 1:

    nixVersions = prev.nixVersions.extend (
      _: nPrev: {
        nix_2_24_sysroot =
          (nPrev.nix_2_24.overrideAttrs (old: {
            patches = (old.patches or [ ]) ++ [
              ./nix-local-overlay-store-regex.patch
            ];
          })).override
            {
              # TODO(jared): delete when https://github.com/NixOS/nixpkgs/pull/356133 is on nixos-unstable
              curl = final.curl.overrideAttrs (old: {
                patches = (old.patches or [ ]) ++ [
                  (final.fetchpatch {
                    url = "https://raw.githubusercontent.com/NixOS/nixpkgs/d508b59825a6c86aa0ba5eedc72042bfbe97e791/pkgs/by-name/cu/curlMinimal/fix-netrc-regression.patch";
                    hash = "sha256-/0MnDxsurz9BGhuf+57XXdWH0WKfexeRuKRD8deRl4Q=";
                  })
                ];
              });
            };
      }
      );

Version 2:


    nix = prev.nix.override (old: {
      curl = final.patched-curl;
      });

# ...

    patched-curl = prev.curl.overrideAttrs (oldAttrs: {
      patches = (oldAttrs.patches or []) ++ [
        # https://github.com/curl/curl/issues/15496
        (prev.fetchpatch {
          url = "https://github.com/curl/curl/commit/f5c616930b5cf148b1b2632da4f5963ff48bdf88.patch";
          hash = "sha256-FlsAlBxAzCmHBSP+opJVrZG8XxWJ+VP2ro4RAl3g0pQ=";
        })
        # https://github.com/curl/curl/issues/15513
        (prev.fetchpatch {
          url = "https://github.com/curl/curl/commit/0cdde0fdfbeb8c35420f6d03fa4b77ed73497694.patch";
          hash = "sha256-WP0zahMQIx9PtLmIDyNSJICeIJvN60VzJGN2IhiEYv0=";
        })
      ];
    });

I tried also explicitly setting my nix version to be sure the first overlay variant would work:

nix.package = pkgs.nixVersions.nix_2_24;

However when even after:

  • rebuild switch

  • restart nix daemon

  • restart computer

Nothing seems to work.

Actually I can confirm version 2 works in my case. I completely forgot I previously pinned nix.package to stable. After removing nix.package = xxx, version 2 just works and no more “Failed to open/read…”. Maybe double check how you apply your overlay. Also you may need to switch to a previous working generation with the old version of curl to rebuild your system if you’re completely blocked by the downloading error.