unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#66901] [PATCH] scripts: edit: Fix relative file-name with 'load-path' option.
@ 2023-11-02 20:34 Simon Tournier
  2023-11-05 14:58 ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Tournier @ 2023-11-02 20:34 UTC (permalink / raw)
  To: 66901
  Cc: Simon Tournier, Christopher Baines, Josselin Poiret,
	Ludovic Courtès, Mathieu Othacehe, Ricardo Wurmus,
	Simon Tournier, Tobias Geerinckx-Rice

* guix/scripts/edit.scm (search-path*): Use 'canonicalize-path' if
'search-path' fails.

Change-Id: I891d63d0d28577a7d1732fc59435828ecc0a5c5a
---
 guix/scripts/edit.scm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Hi,

Using Guix aabfddb, consider:

--8<---------------cut here---------------start------------->8---
$ guix show -L src/example hi
name: hi
version: 2.10
outputs:
+ out: everything
systems: x86_64-linux i686-linux
dependencies: gawk@5.2.1
location: src/example/first.scm:9:2
homepage: https://www.gnu.org/software/hello/
license: GPL 3+
synopsis: Hello, GNU world: An example GNU package
description: Guess what GNU Hello prints!

$ guix edit -L src/example hi
guix edit: error: file 'src/example/first.scm' not found in search path ("src/example" "/gnu/store/yzib23ah0rlmim0j4737g2wrhx1r1q3r-guix-module-union/share/guile/site/3.0" "/gnu/store/84rvhd3j7pfqrh7717cv7ddv2dc8xad5-guile-3.0.9/share/guile/3.0" "/gnu/store/84rvhd3j7pfqrh7717cv7ddv2dc8xad5-guile-3.0.9/share/guile/3.0" "/gnu/store/84rvhd3j7pfqrh7717cv7ddv2dc8xad5-guile-3.0.9/share/guile/site/3.0" "/gnu/store/84rvhd3j7pfqrh7717cv7ddv2dc8xad5-guile-3.0.9/share/guile/site" "/gnu/store/84rvhd3j7pfqrh7717cv7ddv2dc8xad5-guile-3.0.9/share/guile" "/home/simon/.guix-profile/share/guile/site/3.0" "/home/simon/.config/guix/profiles/emacs/emacs/share/guile/site/3.0" "/home/simon/.guix-profile/share/guile/site/3.0" "/home/simon/.config/guix/profiles/emacs/emacs/share/guile/site/3.0")
--8<---------------cut here---------------end--------------->8---

The issue is that the procedure 'search-path' returns #f.  It looks similar as
fixed bug #42543 [1] by d10474c38d58bdc676e64336769dc2e00cdfa8ed.

Here, I do not know how to avoid 'canonicalize-path' when 'search-path'
returns #f because some relative.

WDYT?

1: https://issues.guix.gnu.org/42543

Cheers,
simon


diff --git a/guix/scripts/edit.scm b/guix/scripts/edit.scm
index ff2d529bcf..7ec725fc08 100644
--- a/guix/scripts/edit.scm
+++ b/guix/scripts/edit.scm
@@ -64,7 +64,11 @@ (define %editor
 
 (define (search-path* path file)
   "Like 'search-path' but exit if FILE is not found."
-  (let ((absolute-file-name (search-path path file)))
+  (let ((absolute-file-name (or (search-path path file)
+                                ;; It could be that FILE is a relative name
+                                ;; i.e., not relative to an element of PATH.
+                                (and (file-exists? file)
+                                     (canonicalize-path file)))))
     (unless absolute-file-name
       ;; Shouldn't happen unless somebody fiddled with the 'location' field.
       (leave (G_ "file '~a' not found in search path ~s~%")

base-commit: 28ebbe2be8829a4767b9789c6353ad5e826d1164
-- 
2.41.0





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

* [bug#66901] [PATCH] scripts: edit: Fix relative file-name with 'load-path' option.
  2023-11-02 20:34 [bug#66901] [PATCH] scripts: edit: Fix relative file-name with 'load-path' option Simon Tournier
@ 2023-11-05 14:58 ` Ludovic Courtès
  2023-11-05 15:53   ` bug#66901: " Simon Tournier
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2023-11-05 14:58 UTC (permalink / raw)
  To: Simon Tournier
  Cc: Josselin Poiret, Mathieu Othacehe, Tobias Geerinckx-Rice,
	Ricardo Wurmus, 66901, Christopher Baines

Hi!

Simon Tournier <zimon.toutoune@gmail.com> skribis:

> * guix/scripts/edit.scm (search-path*): Use 'canonicalize-path' if
> 'search-path' fails.

[...]

> $ guix edit -L src/example hi
> guix edit: error: file 'src/example/first.scm' not found in search path ("src/example" "/gnu/store/yzib23ah0rlmim0j4737g2wrhx1r1q3r-guix-module-union/share/guile/site/3.0" "/gnu/store/84rvhd3j7pfqrh7717cv7ddv2dc8xad5-guile-3.0.9/share/guile/3.0" "/gnu/store/84rvhd3j7pfqrh7717cv7ddv2dc8xad5-guile-3.0.9/share/guile/3.0" "/gnu/store/84rvhd3j7pfqrh7717cv7ddv2dc8xad5-guile-3.0.9/share/guile/site/3.0" "/gnu/store/84rvhd3j7pfqrh7717cv7ddv2dc8xad5-guile-3.0.9/share/guile/site" "/gnu/store/84rvhd3j7pfqrh7717cv7ddv2dc8xad5-guile-3.0.9/share/guile" "/home/simon/.guix-profile/share/guile/site/3.0" "/home/simon/.config/guix/profiles/emacs/emacs/share/guile/site/3.0" "/home/simon/.guix-profile/share/guile/site/3.0" "/home/simon/.config/guix/profiles/emacs/emacs/share/guile/site/3.0")
>
>
> The issue is that the procedure 'search-path' returns #f.  It looks similar as
> fixed bug #42543 [1] by d10474c38d58bdc676e64336769dc2e00cdfa8ed.
>
> Here, I do not know how to avoid 'canonicalize-path' when 'search-path'
> returns #f because some relative.

[...]

>  (define (search-path* path file)
>    "Like 'search-path' but exit if FILE is not found."
> -  (let ((absolute-file-name (search-path path file)))
> +  (let ((absolute-file-name (or (search-path path file)
> +                                ;; It could be that FILE is a relative name
> +                                ;; i.e., not relative to an element of PATH.
> +                                (and (file-exists? file)
> +                                     (canonicalize-path file)))))

I think we can remove the ‘canonicalize-path’ call here since we know
that FILE denotes a valid file at that point.  (That’d avoid the extra
work ‘canonicalize-path’ does.)

Otherwise LGTM!

Thanks,
Ludo’.




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

* bug#66901: [PATCH] scripts: edit: Fix relative file-name with 'load-path' option.
  2023-11-05 14:58 ` Ludovic Courtès
@ 2023-11-05 15:53   ` Simon Tournier
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Tournier @ 2023-11-05 15:53 UTC (permalink / raw)
  To: Ludovic Courtès
  Cc: Josselin Poiret, 66901-done, Mathieu Othacehe,
	Tobias Geerinckx-Rice, Ricardo Wurmus, Christopher Baines

Hi,

On Sun, 05 Nov 2023 at 15:58, Ludovic Courtès <ludo@gnu.org> wrote:

> I think we can remove the ‘canonicalize-path’ call here since we know
> that FILE denotes a valid file at that point.  (That’d avoid the extra
> work ‘canonicalize-path’ does.)

Thanks for the review.  Pushed without canonicalize-path as
1eb3133355ef14d6d4c8648504a7e013338779a8.

Cheers,
simon




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

end of thread, other threads:[~2023-11-05 15:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-02 20:34 [bug#66901] [PATCH] scripts: edit: Fix relative file-name with 'load-path' option Simon Tournier
2023-11-05 14:58 ` Ludovic Courtès
2023-11-05 15:53   ` bug#66901: " Simon Tournier

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).