1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 16:51:15 +02:00

Improve error message when a directory is not a flake

So you now get

  $ nix build
  error: path '.' is not a flake (because it does not reference a Git repository)

rather than

  $ nix build
  error: unsupported argument '.'
This commit is contained in:
Eelco Dolstra 2019-09-02 17:33:07 +02:00
parent 5ec2a1ed82
commit 61fdb16aac
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
3 changed files with 39 additions and 20 deletions

View file

@ -145,10 +145,10 @@ FlakeRef::FlakeRef(const std::string & uri_, bool allowRelative)
d.path = absPath(uri);
try {
if (!S_ISDIR(lstat(d.path).st_mode))
throw BadFlakeRef("path '%s' is not a flake (sub)directory");
throw MissingFlake("path '%s' is not a flake (sub)directory", d.path);
} catch (SysError & e) {
if (e.errNo == ENOENT || e.errNo == EISDIR)
throw BadFlakeRef("flake '%s' does not exist");
throw MissingFlake("flake '%s' does not exist", d.path);
throw;
}
while (true) {
@ -156,7 +156,7 @@ FlakeRef::FlakeRef(const std::string & uri_, bool allowRelative)
subdir = baseNameOf(d.path) + (subdir.empty() ? "" : "/" + subdir);
d.path = dirOf(d.path);
if (d.path == "/")
throw BadFlakeRef("path '%s' does not reference a Git repository", uri);
throw MissingFlake("path '%s' is not a flake (because it does not reference a Git repository)", uri);
}
} else
d.path = canonPath(uri);