Hi,

The attached patches handle a chicken-install issue reported by Diego
when fetching srfi-197, which contains an empty file (srfi-197-impl.scm):

  $ chicken-install -r srfi-197
  fetching srfi-197

  Error: (write-bytevector) bad argument type - not a bytevector: #!eof

I've put the fixes in two separate commits because I'm not sure the fix
in 0002-egg-download.scm-Handle-empty-files.patch is the cleanest one.

As per why this issue is not caught by test-new-egg: test-new-egg
doesn't use chicken-install to fetch eggs (it uses henrietta-cache), as
at that point the eggs are not available in cache servers yet.

All the best.
Mario
-- 
https://parenteses.org/mario
>From 4a518f7a099404da6e42843d0f5d6fac5e93305b Mon Sep 17 00:00:00 2001
From: Mario Domenech Goulart <[email protected]>
Date: Sun, 16 Nov 2025 18:47:51 +0100
Subject: [PATCH 1/2] types.db: read-bytevector can also return eof

---
 types.db | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/types.db b/types.db
index 51fb5fd1..4ebc0b16 100644
--- a/types.db
+++ b/types.db
@@ -1641,7 +1641,7 @@
 (chicken.io#write-byte (#(procedure #:enforce) chicken.io#write-byte (fixnum #!optional output-port) undefined))
 (chicken.io#write-line (#(procedure #:enforce) chicken.io#write-line (string #!optional output-port) undefined))
 (chicken.io#write-bytevector (#(procedure #:enforce) chicken.io#write-bytevector (bytevector #!optional output-port fixnum fixnum) undefined))
-(chicken.io#read-bytevector (#(procedure #:enforce) chicken.io#read-bytevector (#!optional * input-port) bytevector))
+(chicken.io#read-bytevector (#(procedure #:enforce) chicken.io#read-bytevector (#!optional * input-port) (or eof bytevector)))
 (chicken.io#read-bytevector! (#(procedure #:enforce) chicken.io#read-bytevector! (bytevector #!optional input-port fixnum fixnum) fixnum))
 
 ;; pretty-print
-- 
2.47.3

>From a5c532fc3858163461f2b9d3c4f2e15b32483ce3 Mon Sep 17 00:00:00 2001
From: Mario Domenech Goulart <[email protected]>
Date: Sun, 16 Nov 2025 18:48:41 +0100
Subject: [PATCH 2/2] egg-download.scm: Handle empty files

In case of oef (what read-bytevector returns on empty files), use
display to write the empty string instead of write-bytevector, which
expects a bytevector as input.
---
 egg-download.scm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/egg-download.scm b/egg-download.scm
index 512fa384..0e1f51da 100644
--- a/egg-download.scm
+++ b/egg-download.scm
@@ -189,7 +189,10 @@
 	               (_ (d "  ~a (~a bytes)~%" name size))
 	      	       (data (read-bytevector size in)) )
 		  (with-output-to-file (make-pathname dest name)
-                    (lambda () (write-bytevector data))
+                    (lambda ()
+                      (if (eof-object? data)
+                          (display "")
+                          (write-bytevector data)))
                     #:binary ) )
 		(get-files (cons name files)) ) ) ) ) ))
 
-- 
2.47.3

Reply via email to