diff --git a/guix/scripts/gc.scm b/guix/scripts/gc.scm index 00f1eb8d00..9a57e5fd1e 100644 --- a/guix/scripts/gc.scm +++ b/guix/scripts/gc.scm @@ -245,7 +245,11 @@ (define (ensure-free-space store space) (define (delete-generations store pattern) ;; Delete the generations matching PATTERN of all the user's profiles. (let ((profiles (delete-duplicates - (filter-map generation-profile (gc-roots))))) + (filter-map (lambda (root) + (and (or (zero? (getuid)) + (user-owned? root)) + (generation-profile root))) + (gc-roots))))) (for-each (lambda (profile) (delete-old-generations store profile pattern)) profiles)))