ignore trailing slash for `guix gc -d' /gnu/store/...something/

  • Done
  • quality assurance status badge
Details
3 participants
  • Cyrill Schenkel
  • Ludovic Courtès
  • Tomáš ?ech
Owner
unassigned
Submitted by
Ludovic Courtès
Severity
normal
L
L
Ludovic Courtès wrote on 3 Feb 2015 21:57
(address . sleep_walker@suse.cz)
87wq3yogrj.fsf@gnu.org
sleep_walker@suse.cz skribis:

Toggle quote (22 lines)
> Package: guix
> Version: 0.8.1
>
> When I invoke `guix gc -d /path', success of the command depends whether /path ends with slash or not:
>
> $ guix gc -d /gnu/store/mgqk0kv5jckrd7l5cwj68fp7cz2l4qqj-luajit-2.0.3/
> guix gc: error: build failed: path `/gnu/store/mgqk0kv5jckrd7l5cwj68fp7cz2l4qqj-luajit-2.0.3/' is not in the Nix store
>
> $ guix gc -d /gnu/store/mgqk0kv5jckrd7l5cwj68fp7cz2l4qqj-luajit-2.0.3
> finding garbage collector roots...
> cannot read potential root `/var/guix/manifests'
> deleting `/gnu/store/73b760g2nr9syhznydgly8r7vl2k9z11-profile'
> deleting `/gnu/store/mgqk0kv5jckrd7l5cwj68fp7cz2l4qqj-luajit-2.0.3'
> deleting `/gnu/store/trash'
> deleting unused links...
> note: currently hard linking saves 247.60 MiB
>
>
> * with the misleading error message it is usability bug
> * it should be safe always try to remove slash from the end
> * other commands may be affected too and the behaviour should be consistent for all commands

What behavior do you think would be appropriate when running, say:

guix gc -d /gnu/store/mgqk0kv5jckrd7l5cwj68fp7cz2l4qqj-luajit-2.0.3/bin/lua

Should it be equivalent to:

guix gc -d /gnu/store/mgqk0kv5jckrd7l5cwj68fp7cz2l4qqj-luajit-2.0.3

I would think so, but I’d like to have feedback.

Thanks,
Ludo’.

PS: Make sure to use bug-guix@gnu.org for bug reports.
T
T
Tomáš ?ech wrote on 25 Feb 2015 21:24
20150225202445.GA10407@venom
Sorry for late response.

On Tue, Feb 03, 2015 at 09:57:04PM +0100, Ludovic Courtès wrote:
Toggle quote (34 lines)
>sleep_walker@suse.cz skribis:
>
>> Package: guix
>> Version: 0.8.1
>>
>> When I invoke `guix gc -d /path', success of the command depends whether /path ends with slash or not:
>>
>> $ guix gc -d /gnu/store/mgqk0kv5jckrd7l5cwj68fp7cz2l4qqj-luajit-2.0.3/
>> guix gc: error: build failed: path `/gnu/store/mgqk0kv5jckrd7l5cwj68fp7cz2l4qqj-luajit-2.0.3/' is not in the Nix store
>>
>> $ guix gc -d /gnu/store/mgqk0kv5jckrd7l5cwj68fp7cz2l4qqj-luajit-2.0.3
>> finding garbage collector roots...
>> cannot read potential root `/var/guix/manifests'
>> deleting `/gnu/store/73b760g2nr9syhznydgly8r7vl2k9z11-profile'
>> deleting `/gnu/store/mgqk0kv5jckrd7l5cwj68fp7cz2l4qqj-luajit-2.0.3'
>> deleting `/gnu/store/trash'
>> deleting unused links...
>> note: currently hard linking saves 247.60 MiB
>>
>>
>> * with the misleading error message it is usability bug
>> * it should be safe always try to remove slash from the end
>> * other commands may be affected too and the behaviour should be consistent for all commands
>
>What behavior do you think would be appropriate when running, say:
>
> guix gc -d /gnu/store/mgqk0kv5jckrd7l5cwj68fp7cz2l4qqj-luajit-2.0.3/bin/lua
>
>Should it be equivalent to:
>
> guix gc -d /gnu/store/mgqk0kv5jckrd7l5cwj68fp7cz2l4qqj-luajit-2.0.3
>
>I would think so, but I’d like to have feedback.

I think so as well.

Toggle quote (6 lines)
>
>Thanks,
>Ludo’.
>
>PS: Make sure to use bug-guix@gnu.org for bug reports.

Sorry about that, I'm still getting used to GNU's bugtracker...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iEYEARECAAYFAlTuL40ACgkQ37XrCapiVCO6CQCdEexeranGGgvtWcf+Ml3FhXC7
oqMAniZvJSkEhK4j42kP4uPshtxrYIOD
=1xNK
-----END PGP SIGNATURE-----


C
C
Cyrill Schenkel wrote on 24 May 2015 14:04
[PATCH] gc: ignore trailing slash or subdirectories for `guix gc -d'
87y4kekwqo.fsf_-_@SIRIUS11.sirius11
From 7385c2ddd4ca50cb80afcd315287eaadff4d8421 Mon Sep 17 00:00:00 2001
From: Cyrill Schenkel <cyrill.schenkel@gmail.com>
Date: Sun, 24 May 2015 13:46:37 +0200
Subject: [PATCH] gc: ignore trailing slash or subdirectories for `guix gc -d'


* guix/scripts/gc.scm (guix-gc): Convert paths to direct store paths.
* guix/store.scm (direct-store-path): Get rid of subdirectories in store path.
* tests/guix-gc.sh: New tests.
---
guix/scripts/gc.scm | 2 +-
guix/store.scm | 7 +++++++
tests/guix-gc.sh | 20 ++++++++++++++++++++
3 files changed, 28 insertions(+), 1 deletion(-)

Toggle diff (68 lines)
diff --git a/guix/scripts/gc.scm b/guix/scripts/gc.scm
index 4bae65a..a250cdc 100644
--- a/guix/scripts/gc.scm
+++ b/guix/scripts/gc.scm
@@ -168,7 +168,7 @@ Invoke the garbage collector.\n"))
(collect-garbage store min-freed)
(collect-garbage store))))
((delete)
- (delete-paths store paths))
+ (delete-paths store (map direct-store-path paths)))
((list-references)
(list-relatives references))
((list-requisites)
diff --git a/guix/store.scm b/guix/store.scm
index fc2f8d9..98b293b 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -121,6 +121,7 @@
derivation-path?
store-path-package-name
store-path-hash-part
+ direct-store-path
log-file))
(define %protocol-version #x10c)
@@ -1038,6 +1039,12 @@ syntactically valid store path."
(and=> (regexp-exec path-rx path)
(cut match:substring <> 1))))
+(define (direct-store-path path)
+ "Return the direct store path part of PATH."
+ (let* ((minimal-prefix-length (+ (string-length (%store-prefix)) 35))
+ (slash-index (string-index path #\/ minimal-prefix-length)))
+ (if slash-index (string-take path slash-index) path)))
+
(define (log-file store file)
"Return the build log file for FILE, or #f if none could be found. FILE
must be an absolute store file name, or a derivation file name."
diff --git a/tests/guix-gc.sh b/tests/guix-gc.sh
index eac9d82..c1eb66c 100644
--- a/tests/guix-gc.sh
+++ b/tests/guix-gc.sh
@@ -64,3 +64,23 @@ guix gc -C 1KiB
# Check trivial error cases.
if guix gc --delete /dev/null;
then false; else true; fi
+
+# Bug #19757
+out="`guix build guile-bootstrap`"
+test -d "$out"
+
+guix gc --delete "$out"
+
+! test -d "$out"
+
+out="`guix build guile-bootstrap`"
+test -d "$out"
+
+guix gc --delete "$out/"
+
+! test -d "$out"
+
+out="`guix build guile-bootstrap`"
+test -d "$out"
+
+guix gc --delete "$out/bin/guile"
--
2.1.4
L
L
Ludovic Courtès wrote on 26 May 2015 22:27
(name . Cyrill Schenkel)(address . cyrill.schenkel@gmail.com)(address . 19757-done@debbugs.gnu.org)
87y4kbkrsz.fsf@gnu.org
Cyrill Schenkel <cyrill.schenkel@gmail.com> skribis:

Toggle quote (11 lines)
> From 7385c2ddd4ca50cb80afcd315287eaadff4d8421 Mon Sep 17 00:00:00 2001
> From: Cyrill Schenkel <cyrill.schenkel@gmail.com>
> Date: Sun, 24 May 2015 13:46:37 +0200
> Subject: [PATCH] gc: ignore trailing slash or subdirectories for `guix gc -d'
>
> Fixes <http://bugs.gnu.org/19757>.
>
> * guix/scripts/gc.scm (guix-gc): Convert paths to direct store paths.
> * guix/store.scm (direct-store-path): Get rid of subdirectories in store path.
> * tests/guix-gc.sh: New tests.

Applied, thank you!

I tweaked ‘direct-store-path’ so that it gracefully handles non-store
file names such as “/dev/null”.

Ludo’.
Closed
?