fetchTree: reject relative file: paths for tarballs#14983
Merged
edolstra merged 2 commits intoNixOS:masterfrom Jan 13, 2026
Merged
fetchTree: reject relative file: paths for tarballs#14983edolstra merged 2 commits intoNixOS:masterfrom
file: paths for tarballs#14983edolstra merged 2 commits intoNixOS:masterfrom
Conversation
Relative paths like `file:./foo.tar.gz` have never worked for tarballs because curl rejects relative file: URLs. Previously this resulted in cryptic curl errors. Now we reject them early with a clear message explaining that relative paths are not supported because there is no defined base directory to resolve them against. See NixOS#12281
file: paths for tarballs
xokdvium
reviewed
Jan 12, 2026
src/libfetchers/tarball.cc
Outdated
Comment on lines
+119
to
+121
| "tarball '%s' uses a relative path. " | ||
| "Relative paths are not supported because the base directory is undefined. " | ||
| "Use an absolute path instead.", |
Contributor
There was a problem hiding this comment.
Not sure we should call this a relative path at all, since file: scheme has no concept of base directory. Might be misleading to call it such. This phrasing makes it sound like it could be theoretically possible if the base directory were defined.
Member
Author
There was a problem hiding this comment.
New error:
… while fetching the input 'file:./relative-path.tar.gz'
error: tarball 'file:./relative-path.tar.gz' must use an absolute path. The 'file' scheme does not support relative paths.
Avoid implying that relative paths could work if a base directory were defined. The file: scheme fundamentally does not support them.
edolstra
approved these changes
Jan 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relative paths like
file:./foo.tar.gzhave never worked for tarballs because curl rejects relative file: URLs. Previously this resulted in cryptic curl errors. Now we reject them early with a clear message explaining that relative paths are not supported because there is no defined base directory to resolve them against.Motivation
Better error messages.
Intentional behavior.
Context
git+file:relative/path#12281 but easier situation.Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.