From: Simon Tournier <zimon.toutoune@gmail.com>
To: 74584@debbugs.gnu.org
Subject: bug#74584: wrong pull/time-machine message when channels.scm does not exit
Date: Thu, 28 Nov 2024 02:26:16 +0100 [thread overview]
Message-ID: <874j3sf8sn.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1061 bytes --]
Hi,
The “bug“:
--8<---------------cut here---------------start------------->8---
$ 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
--8<---------------cut here---------------end--------------->8---
That’s incorrect. What I expect is something as:
--8<---------------cut here---------------start------------->8---
$ 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
--8<---------------cut here---------------end--------------->8---
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’.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: trivial.patch --]
[-- Type: text/x-diff, Size: 1559 bytes --]
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
[-- Attachment #3: Type: text/plain, Size: 1657 bytes --]
It reads:
--8<---------------cut here---------------start------------->8---
$ ./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
--8<---------------cut here---------------end--------------->8---
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’:
--8<---------------cut here---------------start------------->8---
$ 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
--8<---------------cut here---------------end--------------->8---
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
reply other threads:[~2024-11-28 8:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874j3sf8sn.fsf@gmail.com \
--to=zimon.toutoune@gmail.com \
--cc=74584@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.