Skip to content

Commit 43a170a

Browse files
authored
Merge pull request #12277 from DeterminateSystems/warn-relative-git
Warn against the use of relative 'git+file:' flake inputs
2 parents 12aff40 + 3197c19 commit 43a170a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/libfetchers/git.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,17 @@ struct GitInputScheme : InputScheme
435435
//
436436
// See: https://discourse.nixos.org/t/57783 and #9708
437437
//
438-
repoInfo.url = repoInfo.isLocal ? std::filesystem::absolute(url.path).string() : url.to_string();
438+
if (repoInfo.isLocal) {
439+
if (!isAbsolute(url.path)) {
440+
warn(
441+
"Fetching Git repository '%s', which uses a path relative to the current directory. "
442+
"This is not supported and will stop working in a future release. "
443+
"See https://github.com/NixOS/nix/issues/12281 for details.",
444+
url);
445+
}
446+
repoInfo.url = std::filesystem::absolute(url.path).string();
447+
} else
448+
repoInfo.url = url.to_string();
439449

440450
// If this is a local directory and no ref or revision is
441451
// given, then allow the use of an unclean working tree.

0 commit comments

Comments
 (0)