NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.74k stars 1.52k forks source link

progress output from curl inside builder seems to "hang" #8379

Open kirillrdy opened 1 year ago

kirillrdy commented 1 year ago

Describe the bug

Sorry for vague title.

fetchurl from nixpkgs and other dependents eg fetchzip use curl to fetch files. curl usually prints download progress.

When called from builder however curl doesn't print progress, and it looks as if download is not progressing

Steps To Reproduce here is minimal derivation to reproduce

curl.nix

{ pkgs ? import <nixpkgs> { } }:
derivation {
  system = "x86_64-linux";
  name = "foo";
  builder = ./builder.sh;
  curl = pkgs.curl;
  outputHashMode = "flat";
  outputHashAlgo = "sha256";
  outputHash = "sha256-GEcjpQXIreeWdgPiARZYbN4kGzRDGF1YZdIL8k23gFs=";
}

builder.sh

#!/bin/sh
${curl}/bin/curl --insecure https://dl.xonotic.org/xonotic-0.8.5.zip --output foo

Expected behavior

expect to see progress from curl

nix-env --version output

Additional context

I've managed to isolate the issue to this line

https://github.com/NixOS/nix/blob/master/src/libstore/build/local-derivation-goal.cc#L854

  if (dup2(builderOut.get(), STDERR_FILENO) == -1)
            throw SysError("cannot pipe standard error into log file");

removing this line, fixes the curl issue, but obviously it breaks a bunch of other things, I am not familiar enough with this area to fix all the issues, hoping that this makes more sense for nix developers/maintainers

Priorities

Add :+1: to issues you find important.

abhillman commented 7 months ago

I am seeing this issue. One workaround that may work is to delete the derivation with nix-store --delete /path [--ignore-liveness].

thufschmitt commented 7 months ago

@abhillman wrong issue?

@kirillrdy I suspect it's due to stderr not being a tty any more. Not sure what to do about it