!VRULIdgoKmKPzJZzjj:nixos.org

Nix Package Manager development

869 Members
For people hacking on Nix: https://github.com/NixOS/nix Nix maintainers can be reached here.183 Servers

Load older messages


SenderMessageTime
8 Dec 2025
@xokdvium:matrix.orgSergei Zimmerman (xokdvium)

FML. That is fixed on 2.32. Basically it doesn't do pct-decoding as it should:

commit 196c21c5a0e2f9b3149689ea36789cf0478d893a
Author: Farid Zakaria <farid.m.zakaria@gmail.com>
Date:   Wed Jul 16 21:09:59 2025 -0700

    Add helpful messages when file:// used as tarball
    
    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 #12935

diff --git a/src/libfetchers/tarball.cc b/src/libfetchers/tarball.cc
index b0822cc33..59316eabd 100644
--- a/src/libfetchers/tarball.cc
+++ b/src/libfetchers/tarball.cc
@@ -111,6 +111,25 @@ static DownloadTarballResult downloadTarball_(
     const Headers & headers,
     const std::string & displayPrefix)
 {
+
+    // Some friendly error messages for common mistakes.
+    // Namely lets catch when the url is a local file path, but
+    // it is not in fact a tarball.
+    if (url.rfind("file://", 0) == 0) {
+        // Remove "file://" prefix to get the local file path
+        std::string localPath = url.substr(7);
+        if (!std::filesystem::exists(localPath)) {
+            throw Error("tarball '%s' does not exist.", localPath);
+        }
+        if (std::filesystem::is_directory(localPath)) {
+            if (std::filesystem::exists(localPath + "/.git")) {
+                throw Error(
+                    "tarball '%s' is a git repository, not a tarball. Please use `git+file` as the scheme.", localPath);
+            }
+            throw Error("tarball '%s' is a directory, not a file.", localPath);
+        }
+    }
+
     Cache::Key cacheKey{"tarball", {{"url", url}}};
 
     auto cached = settings.getCache()->lookupExpired(cacheKey);
12:38:19
@xokdvium:matrix.orgSergei Zimmerman (xokdvium)

Specifically this:

std::string localPath = url.substr(7);
+        if (!std::filesystem::exists(localPath)) {
+            throw Error("tarball '%s' does not exist.", localPath);
+        }
12:38:59
@xokdvium:matrix.orgSergei Zimmerman (xokdvium) Basically it will fail shamefully when encountering a symbol that gets pct-encoded in the file:// URL and barf early even though the later fetching code does the decoding correctly and since NIX_BUILD_TOP is in a dir that has + in it... 12:41:56
@dramforever:matrix.orgdramforeveroooh this is why it only fails if no sandbox12:43:24
@xokdvium:matrix.orgSergei Zimmerman (xokdvium)Yup...12:43:39
@dramforever:matrix.orgdramforeveroh12:46:04
@dramforever:matrix.orgdramforeverduh12:46:07
@dramforever:matrix.orgdramforever i was trying to --no-sandbox and i don't think that does anything... 12:46:20
@dramforever:matrix.orgdramforeverprobably for the better12:46:34
@dramforever:matrix.orgdramforeverthis is fixed but it's so un-cherry-pick-able13:02:48
@dramforever:matrix.orgdramforeverthere's like a whole new url parsing infrastructure thing added on13:03:08
@xokdvium:matrix.orgSergei Zimmerman (xokdvium) Yeah, I know. Probably just doing a percentDecode on the localPath would be enough 13:03:42
@dramforever:matrix.orgdramforeverupdate on that is i just realized i can repro this locally on linux if i just do sandbox = false16:43:58
@dramforever:matrix.orgdramforeverso i'm running a build with this patch https://github.com/NixOS/nix/pull/1473416:44:11
@dramforever:matrix.orgdramforeverhopefully that would fix it16:44:30
@joerg:thalheim.ioMic92

John Ericson: looks like there is some issue now when using the current stable nix against a new nix daemon?

clan-env % nix develop
path '/home/joerg/git/clan-core/pkgs/clan-cli' does not contain a 'flake.nix', searching up
error:
       … while checking derivation '/nix/store/v8qnm8aabm0fp0v2xf3cavsgwqfgc2bk-clan-env.drv'

       error: derivation has incorrect deferred output, should be '/nix/store/jq6nq5bvdv23xdjajsaj2ay6vni5bkki-clan-env'

clan-env % real-which nix
/nix/store/ah8kqqslr7jig18fd4hzmdk2bhbqs8a7-nix-2.31.2/bin/nix


clan-env % /nix/store/7ykgjirdiwxkdwyh3hypd27ifx7aws29-nix-2.33.0pre20251208_5b5d4cb/bin/nix develop
path '/home/joerg/git/clan-core/pkgs/clan-cli' does not contain a 'flake.nix', [joerg@eve clan-cli]$

16:50:58
@dramforever:matrix.orgdramforevernevermind17:01:56
@dramforever:matrix.orgdramforeverthe tests just fail on linux without sandbox...17:02:15
@dramforever:matrix.orgdramforeverwhat the heck17:02:20
@Ericson2314:matrix.orgJohn Ericson
In reply to @joerg:thalheim.io

John Ericson: looks like there is some issue now when using the current stable nix against a new nix daemon?

clan-env % nix develop
path '/home/joerg/git/clan-core/pkgs/clan-cli' does not contain a 'flake.nix', searching up
error:
       … while checking derivation '/nix/store/v8qnm8aabm0fp0v2xf3cavsgwqfgc2bk-clan-env.drv'

       error: derivation has incorrect deferred output, should be '/nix/store/jq6nq5bvdv23xdjajsaj2ay6vni5bkki-clan-env'

clan-env % real-which nix
/nix/store/ah8kqqslr7jig18fd4hzmdk2bhbqs8a7-nix-2.31.2/bin/nix


clan-env % /nix/store/7ykgjirdiwxkdwyh3hypd27ifx7aws29-nix-2.33.0pre20251208_5b5d4cb/bin/nix develop
path '/home/joerg/git/clan-core/pkgs/clan-cli' does not contain a 'flake.nix', [joerg@eve clan-cli]$

Woah!
17:02:25
@Ericson2314:matrix.orgJohn EricsonAre you doing CA derivations?17:02:31
@xokdvium:matrix.orgSergei Zimmerman (xokdvium)
In reply to @dramforever:matrix.org
the tests just fail on linux without sandbox...
Let me guess, `/homeless-shelter’ exists?
17:04:27
@dramforever:matrix.orgdramforeveri don't think so17:05:11
@dramforever:matrix.orgdramforeveri can try to mess with sandbox-build-dir though17:08:35
@dramforever:matrix.orgdramforevermaybe it's some cgroup and auto-allocate-uids stuff?17:18:34
@joerg:thalheim.ioMic92no.17:29:44
@joerg:thalheim.ioMic92no to what?17:37:20
@joerg:thalheim.ioMic92Probably should be merged before the release: https://github.com/NixOS/nix/pull/1473920:16:00
@joerg:thalheim.ioMic92https://github.com/NixOS/nix/pull/14743 and now this one as well22:27:09
9 Dec 2025
@niksnut:matrix.orgEelcoRelease notes PR, please add anything relevant that's missing: https://github.com/NixOS/nix/pull/1475215:57:43

There are no newer messages yet.


Back to Room ListRoom Version: 6