diff --git a/doc/manual/rl-next/improve-nix_path-error.md b/doc/manual/rl-next/improve-nix_path-error.md new file mode 100644 index 000000000..ab5679719 --- /dev/null +++ b/doc/manual/rl-next/improve-nix_path-error.md @@ -0,0 +1,21 @@ +--- +synopsis: Show error when item from NIX_PATH cannot be downloaded +issues: [] +cls: [] +category: Fixes +credits: [ma27] +--- + +For e.g. `nix-instantiate -I https://example.com/404`, you'd only get a warning if the download failed, such as + + warning: Nix search path entry 'https://example.com/404' cannot be downloaded, ignoring + +Now, the full error that caused the download failure is displayed with a note that the search +path entry is ignored, e.g. + + warning: + … while downloading https://example.com/404 to satisfy NIX_PATH lookup, ignoring search path entry + + warning: unable to download 'https://example.com/404': HTTP error 404 () + + response body: […] diff --git a/lix/libexpr/eval.cc b/lix/libexpr/eval.cc index 530f25d3e..312464721 100644 --- a/lix/libexpr/eval.cc +++ b/lix/libexpr/eval.cc @@ -2,6 +2,7 @@ #include "lix/libexpr/eval-settings.hh" #include "lix/libutil/archive.hh" #include "lix/libutil/async.hh" +#include "lix/libutil/error.hh" #include "lix/libutil/hash.hh" #include "lix/libexpr/primops.hh" #include "lix/libexpr/print-options.hh" @@ -2827,9 +2828,8 @@ try { store, EvalSettings::resolvePseudoUrl(value), "source", false)).tree.storePath; res = { store->toRealPath(storePath) }; } catch (FileTransferError & e) { - logWarning({ - .msg = HintFmt("Nix search path entry '%1%' cannot be downloaded, ignoring", value) - }); + e.addTrace(nullptr, "while downloading %s to satisfy NIX_PATH lookup, ignoring search path entry", value); + logWarning(e.info()); res = std::nullopt; } }