Skip to content

Add helpful messages when file:// used as tarball#13486

Merged
tomberek merged 1 commit intoNixOS:masterfrom
fzakaria:issue-12935
Jul 17, 2025
Merged

Add helpful messages when file:// used as tarball#13486
tomberek merged 1 commit intoNixOS:masterfrom
fzakaria:issue-12935

Conversation

@fzakaria
Copy link
Contributor

Motivation

When file:// is used accidentally in a flake as the source it is expected to be a tarball by default.
Add some friendlier error messages to either inform the user this is not in fact a tarball or if it's a git directory, let them know they can use git+file.

Please see #12935 for more in depth motivation.

fixes #12935

Validation

** Missing directory **

nix build file://$HOME/code/github.com/does-not-exist
error:
       … while fetching the input 'file:///home/fmzakari/code/github.com/does-not-exist'

       error: tarball '/home/fmzakari/code/github.com/does-not-exist' does not exist.

** directory BUT is git **

nix build file://$HOME/code/github.com/fzakaria/fzakaria.com
error:
       … while fetching the input 'file:///home/fmzakari/code/github.com/fzakaria/fzakaria.com'

       error: tarball '/home/fmzakari/code/github.com/fzakaria/fzakaria.com' is a git repository, not a tarball. Please use `git+file` as the scheme.

** directory BUT is NOT git **

nix build file://$HOME/code/github.com/fzakaria
error:
       … while fetching the input 'file:///home/fmzakari/code/github.com/fzakaria'

       error: tarball '/home/fmzakari/code/github.com/fzakaria' is a directory, not a file.

Add 👍 to pull requests you find important.

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

@fzakaria fzakaria requested a review from edolstra as a code owner July 17, 2025 04:14
@github-actions github-actions bot added the fetching Networking with the outside (non-Nix) world, input locking label Jul 17, 2025
When `file://` is used accidentally in a flake as the source it is
expected to be a tarball by default.

Add some friendlier error messages to either inform the user this is not
in fact a tarball or if it's a git directory, let them know they can use
`git+file`.

fixes NixOS#12935
@tomberek tomberek merged commit de1d91f into NixOS:master Jul 17, 2025
12 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bad error when referring to local repo by git url

2 participants