Hi all,

I had a look at #1647 and the fix seems to me to be pretty
straightforward.  The build.bat which chicken-install creates
contains a "cd" command, but on Windows, cd won't change to
the corresponding drive, so when we then try to compile the
source file, we'll get an error because we're still on the other

The fix is to first switch drives, then run cd.

While working on this, I discovered that decompose-directory crashes
on Windows when the path has a drive in it, so the first patch first
fixes that bug, the second patch actually fixes the bug from the ticket.

BTW, I find decompose-directory a bit awkward when all I want is the
drive letter.  I thought about adding the drive letter to
decompose-pathname but that would be a breaking change.

It would be nice to have pathname-drive and pathname-replace-drive
procedures, but that's weird and inconsistent if decompose-pathname
doesn't yield the drive letter.  So for now I think the patch is fine
as it is.  It's still a bit awkward though.

From 9a40e5f993d8e7051996f1a0974a3d3ad8e70ee0 Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Sat, 9 Nov 2019 16:52:36 +0100
Subject: [PATCH 1/2] Fix crash in decompose-directory on Windows

We took the ##sys#size of a fixnum, which is incorrect.
 NEWS         | 2 ++
 pathname.scm | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 64b8f6db..d1511162 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,8 @@
   - The procedures `record-printer` and `set-record-printer!` and a
     corresponding SRFI-17 setter have been added. These deprecate
     `define-record-printer` which isn't a "real" definition (see #1294).
+  - On Windows, `decompose-directory` no longer crashes when a drive
+    letter is present in the supplied path string.
 - Runtime system
   - Quoted empty keywords like ||: and :|| are now read like prescribed
diff --git a/pathname.scm b/pathname.scm
index dd2ab467..3c58f688 100644
--- a/pathname.scm
+++ b/pathname.scm
@@ -318,7 +318,7 @@
                 ; else is a prefix
                 (let ((rst (cdr decomp))
                       (elen (##sys#size 1st)))
-                  (if (fx= olen (##sys#size elen))
+                  (if (fx= olen elen)
                       ; then origin is a list prefix
                       ; else origin is a string prefix

From 9b99167297b1679fb3564080522f568d1e599297 Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Sat, 9 Nov 2019 17:02:15 +0100
Subject: [PATCH 2/2] Change to the drive before changing directory when
 running egg commands

On Windows, changing to the directory including the drive will just
set the working directory of that drive, but it won't actually change
to that working directory on that drive.  So, we first change to the
drive before changing directories.

Fixes #1647
 NEWS            | 2 ++
 egg-compile.scm | 9 +++++++++
 2 files changed, 11 insertions(+)

diff --git a/NEWS b/NEWS
index d1511162..d9c12827 100644
--- a/NEWS
+++ b/NEWS
@@ -50,6 +50,8 @@
   - chicken-install now correctly checks server response code to avoid
     interpreting error response bodies (like 404, 500) as Scheme code.
   - chicken-install now follows HTTP redirects when downloading eggs.
+  - chicken-install will now change to the correct drive before
+    attempting to change to the egg directory (fixes #1647).
diff --git a/egg-compile.scm b/egg-compile.scm
index 0fd9c242..de545068 100644
--- a/egg-compile.scm
+++ b/egg-compile.scm
@@ -100,6 +100,11 @@
 (define (cd-command platform) "cd")
+(define (change-drive-command platform drive)
+  (case platform
+    ((unix) #f)
+    ((windows) drive)))		    ; Should already include the colon
 (define (uses-compiled-import-library? mode)
   (not (and (eq? mode 'host) staticbuild)))
@@ -1085,6 +1090,10 @@
     (with-output-to-file dest
       (lambda ()
         (prefix platform)
+	(receive (drive root parts) (decompose-directory srcdir)
+	  (let ((cmd (change-drive-command platform drive)))
+	    (when cmd
+	      (print cmd))))
         (print (cd-command platform) " " (qs* srcdir platform #t))
           (lambda (cmd) (cmd srcdir platform))

Attachment: signature.asc
Description: PGP signature

Reply via email to