From 5327953d299eba0b6de4e88bacf4bba9022bb5e2 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Thu, 12 Dec 2024 15:49:25 -0800 Subject: [PATCH] Log fetchers as they're run It's very difficult to figure out which error messages are fatal or even which fetchers they correspond to. To fix this, we print the command we're going to run to attempt a fetch for each fetcher we try. Before: ``` $ cabal2nix https://github.com/iand675/hs-sqlcommenter.git error: failed to open archive: Unrecognized archive format Initialized empty Git repository in /private/tmp/git-checkout-tmp-REpu3aRm/hs-sqlcommenter/.git/ remote: Enumerating objects: 16, done. remote: Counting objects: 100% (16/16), done. remote: Compressing objects: 100% (12/12), done. remote: Total 16 (delta 0), reused 16 (delta 0), pack-reused 0 (from 0) Unpacking objects: 100% (16/16), 14.14 KiB | 1.18 MiB/s, done. From https://github.com/iand675/hs-sqlcommenter * branch HEAD -> FETCH_HEAD Switched to a new branch 'fetchgit' removing `.git'... error: path '/tmp' is a symlink abort: 'https://github.com/iand675/hs-sqlcommenter.git' does not appear to be an hg repository: ---%<--- (text/html; charset=utf-8) ... ``` After: ``` $ cabal2nix https://github.com/iand675/hs-sqlcommenter.git $ nix-prefetch-url https://github.com/iand675/hs-sqlcommenter.git $ nix-prefetch-url --unpack https://github.com/iand675/hs-sqlcommenter.git error: failed to open archive: Unrecognized archive format [0.1 MiB DL] $ nix-prefetch-git --fetch-submodules https://github.com/iand675/hs-sqlcommenter.git Initialized empty Git repository in /private/tmp/git-checkout-tmp-DRzhuqlX/hs-sqlcommenter/.git/ remote: Enumerating objects: 16, done. remote: Counting objects: 100% (16/16), done. remote: Compressing objects: 100% (12/12), done. remote: Total 16 (delta 0), reused 16 (delta 0), pack-reused 0 (from 0) Unpacking objects: 100% (16/16), 14.14 KiB | 336.00 KiB/s, done. From https://github.com/iand675/hs-sqlcommenter * branch HEAD -> FETCH_HEAD Switched to a new branch 'fetchgit' removing `.git'... error: path '/tmp' is a symlink $ nix-prefetch-hg https://github.com/iand675/hs-sqlcommenter.git abort: 'https://github.com/iand675/hs-sqlcommenter.git' does not appear to be an hg repository: ---%<--- (text/html; charset=utf-8) ... ``` --- cabal2nix/src/Distribution/Nixpkgs/Fetch.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cabal2nix/src/Distribution/Nixpkgs/Fetch.hs b/cabal2nix/src/Distribution/Nixpkgs/Fetch.hs index 1f2891e0c..0bbd7b9a5 100644 --- a/cabal2nix/src/Distribution/Nixpkgs/Fetch.hs +++ b/cabal2nix/src/Distribution/Nixpkgs/Fetch.hs @@ -236,6 +236,8 @@ fetchWith (supportsRev, kind) source = do : [ sourceRevision source | supportsRev ] ++ hashToList (sourceHash source) + liftIO $ hPutStrLn stderr $ "$ " ++ unwords (script:args) + MaybeT $ liftIO $ do envs <- getEnvironment (Nothing, Just stdoutH, _, processH) <-