diff options
| author | David Thompson <dthompson2@worcester.edu> | 2015-11-03 09:02:10 -0500 |
|---|---|---|
| committer | David Thompson <dthompson2@worcester.edu> | 2015-11-03 11:41:04 -0500 |
| commit | 00bfa7ea25b4612d730b057308b304d0131bee03 (patch) | |
| tree | 94ba11729f2f8108532bf69a5b2da3adff7bab02 | |
| parent | b7d48312bbfc7bdbb3895eb10edc352eeb555b98 (diff) | |
scripts: environment: Display friendly container error messages.
* guix/scripts/environment.scm (assert-container-features): New
procedure.
(guix-environment): Use it.
| -rw-r--r-- | guix/scripts/environment.scm | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index 45b54a92971..97410f4e098 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm | |||
| @@ -437,6 +437,21 @@ Otherwise, return the derivation for the Bash package." | |||
| 437 | opts | 437 | opts |
| 438 | (alist-cons 'exec command opts))))) | 438 | (alist-cons 'exec command opts))))) |
| 439 | 439 | ||
| 440 | (define (assert-container-features) | ||
| 441 | "Check if containers can be created and exit with an informative error | ||
| 442 | message if any test fails." | ||
| 443 | (unless (user-namespace-supported?) | ||
| 444 | (report-error (_ "cannot create container: user namespaces unavailable\n")) | ||
| 445 | (leave (_ "is your kernel version < 3.10?\n"))) | ||
| 446 | |||
| 447 | (unless (unprivileged-user-namespace-supported?) | ||
| 448 | (report-error (_ "cannot create container: unprivileged user cannot create user namespaces\n")) | ||
| 449 | (leave (_ "please set /proc/sys/kernel/unprivileged_userns_clone to \"1\"\n"))) | ||
| 450 | |||
| 451 | (unless (setgroups-supported?) | ||
| 452 | (report-error (_ "cannot create container: /proc/self/setgroups does not exist\n")) | ||
| 453 | (leave (_ "is your kernel version < 3.19?\n")))) | ||
| 454 | |||
| 440 | ;; Entry point. | 455 | ;; Entry point. |
| 441 | (define (guix-environment . args) | 456 | (define (guix-environment . args) |
| 442 | (with-error-handling | 457 | (with-error-handling |
| @@ -474,6 +489,9 @@ Otherwise, return the derivation for the Bash package." | |||
| 474 | '())) | 489 | '())) |
| 475 | inputs)) | 490 | inputs)) |
| 476 | eq?))) | 491 | eq?))) |
| 492 | |||
| 493 | (when container? (assert-container-features)) | ||
| 494 | |||
| 477 | (with-store store | 495 | (with-store store |
| 478 | (run-with-store store | 496 | (run-with-store store |
| 479 | (mlet* %store-monad ((inputs (lower-inputs | 497 | (mlet* %store-monad ((inputs (lower-inputs |
