Skip to content

Commit

Permalink
Log fetchers as they're run
Browse files Browse the repository at this point in the history
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)
...
```
  • Loading branch information
9999years committed Dec 12, 2024
1 parent 706caab commit 5327953
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cabal2nix/src/Distribution/Nixpkgs/Fetch.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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) <-
Expand Down

0 comments on commit 5327953

Please sign in to comment.