unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#35776: Test guix-pack-localstatedir.sh and guix-pack-relocatable.sh crash when /gnu/store doesn't exist
@ 2019-05-17 13:47 Ting-Wei Lan
  2019-05-18 10:29 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Ting-Wei Lan @ 2019-05-17 13:47 UTC (permalink / raw)
  To: 35776

[-- Attachment #1: Type: text/plain, Size: 2822 bytes --]

When running these two tests in a clean environment without having Guix
installed first, they crash when trying to obtain the value of
localstatedir.
+ guix pack --version
guix pack (GNU Guix) 1.0.0.711-f52e8-dirty
Copyright (C) 2019 the Guix authors
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
++ guile2.2 -c '(use-modules (guix config))(display %storedir)'
+ NIX_STORE_DIR=/gnu/store
++ guile2.2 -c '(use-modules (guix config))(display %localstatedir)'
Backtrace:
In ice-9/eval.scm:
    619:8 19 (_ #(#(#<directory (guile-user) 564bef205140>)))
In ice-9/command-line.scm:
   181:18 18 (_ #<input: string 564bef21ca80>)
In unknown file:
          17 (eval (use-modules (guix config)) #<directory (guile-us…>)
In ice-9/eval.scm:
   721:20 16 (primitive-eval (use-modules (guix config)))
In ice-9/psyntax.scm:
  1235:36 15 (expand-top-sequence ((use-modules (guix config))) _ _ # …)
  1182:24 14 (parse _ (("placeholder" placeholder)) ((top) #(# # …)) …)
   285:10 13 (parse _ (("placeholder" placeholder)) (()) _ c&e (eval) …)
In ice-9/boot-9.scm:
  3377:20 12 (process-use-modules _)
   222:17 11 (map1 (((guix config))))
  3378:31 10 (_ ((guix config)))
  2800:17  9 (resolve-interface (guix config) #:select _ #:hide _ # _ …)
In ice-9/threads.scm:
    390:8  8 (_ _)
In ice-9/boot-9.scm:
  2726:13  7 (_)
In ice-9/threads.scm:
    390:8  6 (_ _)
In ice-9/boot-9.scm:
  2994:20  5 (_)
   2312:4  4 (save-module-excursion #<procedure 564bef1bf1b0 at ice-…>)
  3014:26  3 (_)
In unknown file:
           2 (primitive-load-path "guix/config" #<procedure 564bef15…>)
In guix/config.scm:
     71:6  1 (_)
In unknown file:
           0 (canonicalize-path "/gnu/store")
ERROR: In procedure canonicalize-path:
In procedure canonicalize-path: No such file or directory
+ localstatedir=
FAIL tests/guix-pack-localstatedir.sh (exit status: 1)
It seems to me that the reason is that NIX_STORE_DIR is exported by
test-env script, so the line
NIX_STORE_DIR="`guile -c '(use-modules (guix config))(display %storedir)'`"
not only changes the value of shell variable NIX_STORE_DIR but also
exports it to the environment.
Therefore, the next line
localstatedir="`guile -c '(use-modules (guix config))(display
%localstatedir)'`"
crashes at guix/config.scm when running the code
(define %store-directory
  (or (and=> (getenv "NIX_STORE_DIR") canonicalize-path)
      %storedir))
because NIX_STORE_DIR points to a non-existent path /gnu/store.
I attached a patch to avoid the crash by delaying the modification
to NIX_STORE_DIR, but I am not sure if it is correct to do so.

[-- Attachment #2: guix-1.0.0-tests-guix-pack-localstatedir.patch --]
[-- Type: text/x-patch, Size: 1496 bytes --]

diff --git a/tests/guix-pack-localstatedir.sh b/tests/guix-pack-localstatedir.sh
index b734b0f..41afda1 100644
--- a/tests/guix-pack-localstatedir.sh
+++ b/tests/guix-pack-localstatedir.sh
@@ -27,8 +27,9 @@ guix pack --version
 # the test in the user's global store if possible, on the grounds that
 # binaries may already be there or can be built or downloaded inexpensively.
 
-NIX_STORE_DIR="`guile -c '(use-modules (guix config))(display %storedir)'`"
+nix_store_dir="`guile -c '(use-modules (guix config))(display %storedir)'`"
 localstatedir="`guile -c '(use-modules (guix config))(display %localstatedir)'`"
+NIX_STORE_DIR="$nix_store_dir"
 GUIX_DAEMON_SOCKET="$localstatedir/guix/daemon-socket/socket"
 export NIX_STORE_DIR GUIX_DAEMON_SOCKET
 
diff --git a/tests/guix-pack-relocatable.sh b/tests/guix-pack-relocatable.sh
index 38dcf1e..b276fdc 100644
--- a/tests/guix-pack-relocatable.sh
+++ b/tests/guix-pack-relocatable.sh
@@ -27,8 +27,9 @@ guix pack --version
 # run it on the user's global store if possible, on the grounds that binaries
 # may already be there or can be built or downloaded inexpensively.
 
-NIX_STORE_DIR="`guile -c '(use-modules (guix config))(display %storedir)'`"
+nix_store_dir="`guile -c '(use-modules (guix config))(display %storedir)'`"
 localstatedir="`guile -c '(use-modules (guix config))(display %localstatedir)'`"
+NIX_STORE_DIR="$nix_store_dir"
 GUIX_DAEMON_SOCKET="$localstatedir/guix/daemon-socket/socket"
 export NIX_STORE_DIR GUIX_DAEMON_SOCKET
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#35776: Test guix-pack-localstatedir.sh and guix-pack-relocatable.sh crash when /gnu/store doesn't exist
  2019-05-17 13:47 bug#35776: Test guix-pack-localstatedir.sh and guix-pack-relocatable.sh crash when /gnu/store doesn't exist Ting-Wei Lan
@ 2019-05-18 10:29 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2019-05-18 10:29 UTC (permalink / raw)
  To: Ting-Wei Lan; +Cc: 35776-done

Ting-Wei Lan <lantw44@gmail.com> skribis:

> It seems to me that the reason is that NIX_STORE_DIR is exported by
> test-env script, so the line
> NIX_STORE_DIR="`guile -c '(use-modules (guix config))(display %storedir)'`"
> not only changes the value of shell variable NIX_STORE_DIR but also
> exports it to the environment.
> Therefore, the next line
> localstatedir="`guile -c '(use-modules (guix config))(display
> %localstatedir)'`"
> crashes at guix/config.scm when running the code
> (define %store-directory
>   (or (and=> (getenv "NIX_STORE_DIR") canonicalize-path)
>       %storedir))
> because NIX_STORE_DIR points to a non-existent path /gnu/store.
> I attached a patch to avoid the crash by delaying the modification
> to NIX_STORE_DIR, but I am not sure if it is correct to do so.

Indeed.  Pushed as baab87ac49e3f0f873e17eb16db9781189b1f2d1, thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-18 10:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-17 13:47 bug#35776: Test guix-pack-localstatedir.sh and guix-pack-relocatable.sh crash when /gnu/store doesn't exist Ting-Wei Lan
2019-05-18 10:29 ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).