Skip to content

fetchTree: reject relative file: paths for tarballs#14983

Merged
edolstra merged 2 commits intoNixOS:masterfrom
roberth:fetchTree-relative-file
Jan 13, 2026
Merged

fetchTree: reject relative file: paths for tarballs#14983
edolstra merged 2 commits intoNixOS:masterfrom
roberth:fetchTree-relative-file

Conversation

@roberth
Copy link
Member

@roberth roberth commented Jan 12, 2026

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.

Motivation

Better error messages.
Intentional behavior.

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

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
@roberth roberth requested a review from edolstra as a code owner January 12, 2026 14:02
@github-actions github-actions bot added with-tests Issues related to testing. PRs with tests have some priority fetching Networking with the outside (non-Nix) world, input locking labels Jan 12, 2026
@roberth roberth changed the title fetchTree: reject relative file: paths for tarballs fetchTree: reject relative file: paths for tarballs Jan 12, 2026
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.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 edolstra added this pull request to the merge queue Jan 13, 2026
Merged via the queue into NixOS:master with commit 53e942b Jan 13, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fetching Networking with the outside (non-Nix) world, input locking with-tests Issues related to testing. PRs with tests have some priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants