mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
fetchers: Add helpful hint for file+git URL scheme error
At least one user has probably used `file+git://` when they mean `git+file://`, maybe thinking of it as "a file-based git repository". This adds a specific error message to hint at the correct URL scheme format and may save some users from resorting to `path:///` and copying an entire repo.
This commit is contained in:
parent
7e8db2eb59
commit
387eceff45
1 changed files with 7 additions and 0 deletions
|
|
@ -5,6 +5,7 @@
|
||||||
#include "nix/util/json-utils.hh"
|
#include "nix/util/json-utils.hh"
|
||||||
#include "nix/fetchers/fetch-settings.hh"
|
#include "nix/fetchers/fetch-settings.hh"
|
||||||
#include "nix/fetchers/fetch-to-store.hh"
|
#include "nix/fetchers/fetch-to-store.hh"
|
||||||
|
#include "nix/util/url.hh"
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
|
@ -65,6 +66,12 @@ Input Input::fromURL(const Settings & settings, const ParsedURL & url, bool requ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Provide a helpful hint when user tries file+git instead of git+file
|
||||||
|
auto parsedScheme = parseUrlScheme(url.scheme);
|
||||||
|
if (parsedScheme.application == "file" && parsedScheme.transport == "git") {
|
||||||
|
throw Error("input '%s' is unsupported; did you mean 'git+file' instead of 'file+git'?", url);
|
||||||
|
}
|
||||||
|
|
||||||
throw Error("input '%s' is unsupported", url);
|
throw Error("input '%s' is unsupported", url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue