wrong pull/time-machine message when channels.scm does not exit

  • Open
  • quality assurance status badge
Details
One participant
  • Simon Tournier
Owner
unassigned
Submitted by
Simon Tournier
Severity
normal

Debbugs page

Simon Tournier wrote 3 months ago
(address . bug-guix@gnu.org)
874j3sf8sn.fsf@gmail.com
Hi,

The “bug“:

Toggle snippet (7 lines)
$ ls channels.scm
ls: cannot access 'channels.scm': No such file or directory

$ guix time-machine -q -C channels.scm -- help
guix time-machine: error: 'channels.scm' did not return a list of channels

That’s incorrect. What I expect is something as:

Toggle snippet (8 lines)
$ ls foo.scm
ls: cannot access 'foo.scm': No such file or directory

$ guix time-machine -q -C foo.scm -- help
guix time-machine: error: failed to load 'foo.scm':
ice-9/boot-9.scm:2190:9: In procedure primitive-load-path: Unable to find file "guix/foo.scm" in load path

Although the second part can be confusing for regular user. And
although I think the message is also incorrect.

Well, the story is about ’load*’ from module (guix ui). Using this
trivial patch with some ’pk’.
Toggle diff (37 lines)
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 58d3cd7e83..d294df4f37 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -752,6 +752,7 @@ (define (channel-list opts)
(define (load-channels file)
(let ((result (load* file (make-user-module '((guix channels))))))
+ (pk 'load-channels result)
(if (and (list? result) (every channel? result))
result
(leave (G_ "'~a' did not return a list of channels~%") file))))
diff --git a/guix/ui.scm b/guix/ui.scm
index eba12c8616..651cea4ff7 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -250,7 +250,11 @@ (define* (load* file user-module
;; 'primitive-load', so that FILE is compiled, which then allows
;; us to provide better error reporting with source line numbers.
(without-compiler-optimizations
- (load (try-canonicalize-path file))))
+ (begin
+ (pk 'file file)
+ (pk 'try-canonicalize-path (try-canonicalize-path file))
+ (pk 'load-file (load file))
+ (load (try-canonicalize-path file)))))
(const #f))))))
(lambda _
;; XXX: Errors are reported from the pre-unwind handler below, but
@@ -262,6 +266,7 @@ (define* (load* file user-module
(let* ((stack (make-stack #t handle-error tag))
(frame (last-frame-with-source stack)))
+ (pk 'let-raise-error)
(report-load-error file args frame)
(case on-error
It reads:

Toggle snippet (12 lines)
$ ./pre-inst-env guix time-machine -q -C channels.scm -- help

;;; (file "channels.scm")

;;; (try-canonicalize-path "channels.scm")

;;; (load-file #<unspecified>)

;;; (load-channels #<unspecified>)
guix time-machine: error: 'channels.scm' did not return a list of channels

In other words, instead of raising an error, it returns #<unspecified>
and thus because ’load-channels’ tests against ’list?’ which
#<unspecified> is obviously not then bang!

Bah the easy fix is to check with ’unspecified?’ directly in
’load-channels’. But that does not really fix the issue, IMHO.

The issue is that because a file named channels.scm is around in
load-path. For instance, let say the non-existent file is named
’packages.scm’:

Toggle snippet (7 lines)
$ ls packages.scm
ls: cannot access 'packages.scm': No such file or directory

$ guix time-machine -q -C packages.scm -- help
guix time-machine: error: 'packages.scm' did not return a list of channels

In other words, is the comment accurate

;; Give 'load' an absolute file name so that it doesn't try to
;; search for FILE in %LOAD-PATH.

?

Well, since I am not sure to get the use case of
’try-canonicalize-path’, then I don’t know what could be the best fix.
But I guess ’canonicalize-path’ is not doing what we expect, right?

Cheers,
simon
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 74584@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 74584
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help