GNU bug report logs - #21613
Include messes up when compiling file in load path

Previous Next

Package: guile;

Reported by: taylanbayirli <at> gmail.com (Taylan Ulrich Bayırlı/Kammer)

Date: Sun, 4 Oct 2015 14:37:02 UTC

Severity: normal

To reply to this bug, email your comments to 21613 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#21613; Package guile. (Sun, 04 Oct 2015 14:37:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to taylanbayirli <at> gmail.com (Taylan Ulrich Bayırlı/Kammer):
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Sun, 04 Oct 2015 14:37:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: taylanbayirli <at> gmail.com (Taylan Ulrich Bayırlı/Kammer)
To: bug-guile <at> gnu.org
Subject: Include messes up when compiling file in load path
Date: Sun, 04 Oct 2015 16:36:21 +0200
When a file to be compiled, A.scm, contains (include "B.scm"), the
compiler fails to find B.scm if the directory containing A and B are in
Guile's load path.

Here's a shell transcript showcasing the bug:

--- snip ---
$ mkdir test
$ echo '(include "test2.scm")' > test/test1.scm
$ echo '(display "foo\n")' > test/test2.scm
$ pwd
/home/taylan
$ export GUILE_LOAD_PATH=/home/taylan/test
$ unset GUILE_LOAD_COMPILED_PATH
$ guile -q
GNU Guile 2.0.11
Copyright (C) 1995-2014 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (compile-file "/home/taylan/test/test1.scm")
ice-9/boot-9.scm:106:20: In procedure #<procedure 248a580 at ice-9/boot-9.scm:97:6 (thrown-k . args)>:
ice-9/boot-9.scm:106:20: In procedure open-file: No such file or directory: "./test2.scm"

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(#{ g269}#) [1]>
--- snip ---

This seems to be related to 'compile-file' setting
'%file-port-name-canonicalization' to 'relative', but I don't know what
the correct fix is.

Taylan




Information forwarded to bug-guile <at> gnu.org:
bug#21613; Package guile. (Sun, 04 Oct 2015 22:32:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: taylanbayirli <at> gmail.com (Taylan Ulrich Bayırlı/Kammer)
To: bug-guile <at> gnu.org
Subject: Re: Include messes up when compiling file in load path
Date: Mon, 05 Oct 2015 00:31:34 +0200
[Message part 1 (text/plain, inline)]
taylanbayirli <at> gmail.com (Taylan Ulrich "Bayırlı/Kammer") writes:

> This seems to be related to 'compile-file' setting
> '%file-port-name-canonicalization' to 'relative', but I don't know
> what the correct fix is.

With the following trivial patch changing 'relative' to 'absolute',
Guile's test suite passes and the bug seems to be fixed, but I still
don't know whether this is the right fix...

[0001-Fix-include-for-files-in-load-path.patch (text/x-diff, inline)]
From 3e508926631a6fe3d81f6a584352562afc0e96ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
 <taylanbayirli <at> gmail.com>
Date: Mon, 5 Oct 2015 00:15:56 +0200
Subject: [PATCH] Fix 'include' for files in load path.

Fixes <http://debbugs.gnu.org/21613>.

* module/system/base/compile.scm (compile-file): Set
  %file-port-name-canonicalization to 'absolute by default.
(compile-and-load): Ditto.
---
 module/system/base/compile.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/module/system/base/compile.scm b/module/system/base/compile.scm
index c522b74..66eec44 100644
--- a/module/system/base/compile.scm
+++ b/module/system/base/compile.scm
@@ -136,7 +136,7 @@
                        (to 'objcode)
                        (env (default-environment from))
                        (opts '())
-                       (canonicalization 'relative))
+                       (canonicalization 'absolute))
   (with-fluids ((%file-port-name-canonicalization canonicalization))
     (let* ((comp (or output-file (compiled-file-name file)
                      (error "failed to create path for auto-compiled file"
@@ -157,7 +157,7 @@
 
 (define* (compile-and-load file #:key (from (current-language)) (to 'value)
                            (env (current-module)) (opts '())
-                           (canonicalization 'relative))
+                           (canonicalization 'absolute))
   (with-fluids ((%file-port-name-canonicalization canonicalization))
     (read-and-compile (open-input-file file)
                       #:from from #:to to #:opts opts
-- 
2.5.0


Information forwarded to bug-guile <at> gnu.org:
bug#21613; Package guile. (Tue, 21 Jun 2016 08:50:02 GMT) Full text and rfc822 format available.

Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: taylanbayirli <at> gmail.com (Taylan Ulrich Bayırlı/Kammer)
To: bug-guile <at> gnu.org
Cc: wingo <at> pobox.com
Subject: Re: Include messes up when compiling file in load path
Date: Tue, 21 Jun 2016 10:49:10 +0200
Ping with CC to Andy. :-)




Information forwarded to bug-guile <at> gnu.org:
bug#21613; Package guile. (Fri, 24 Jun 2016 14:50:02 GMT) Full text and rfc822 format available.

Message #14 received at 21613 <at> debbugs.gnu.org (full text, mbox):

From: Andy Wingo <wingo <at> pobox.com>
To: taylanbayirli <at> gmail.com (Taylan Ulrich "Bayırlı/Kammer")
Cc: 21613 <at> debbugs.gnu.org
Subject: Re: bug#21613: Include messes up when compiling file in load path
Date: Fri, 24 Jun 2016 16:49:05 +0200
On Sun 04 Oct 2015 16:36, taylanbayirli <at> gmail.com (Taylan Ulrich "Bayırlı/Kammer") writes:

> $ mkdir test
> $ echo '(include "test2.scm")' > test/test1.scm
> $ echo '(display "foo\n")' > test/test2.scm
> $ pwd
> /home/taylan
> $ export GUILE_LOAD_PATH=/home/taylan/test
> $ unset GUILE_LOAD_COMPILED_PATH
> $ guile -L test test/test1.scm
...
> ERROR: In procedure open-file:
> ERROR: In procedure open-file: No such file or directory: "./test2.scm"

The way this works is that test/test1.scm is opened.  To set the
port-filename of the port, Guile uses "relative" canonicalization of the
path, which will result in "test1.scm" being the port-filename, as we
found test1.scm in test/.  After that it all breaks down -- the
intention is for `include' of a relative path to look for it relative to
the dirname of the file doing the including, but (dirname "test1.scm")
is ".", so it looks for "./test2.scm"... bogus.

The intention of relative canonicalization is to allow for errors to be
signalled relative to a path-relative file name.  For example in a
recent backtrace:

In ice-9/psyntax.scm:
  1200:36  5 (expand-top-sequence ((include "test2.scm")) _ _ #f e # #)

The fact that it's ice-9/psyntax.scm comes from there.  You can build
the file locally and install it and it the debugging information doesn't
embed the full dirname of the build tree.

But, for that to work well, you really need `include-from-path' and not
`include'.  All of the uses of `include' in Guile itself are really
`include-from-path'.  And if you use `include' in a file which is in a
path... well I guess that's not working.

Clearly going backwards from a relative path to an absolute path is not
going to work.  I guess my only proposal would be to include the
absolute path of a file port, in addition to the relative path.  I guess
that would be somewhere around the call to fport_canonicalize_filename
in fports.c.

Thoughts?

Andy




This bug report was last modified 7 years and 279 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.