rename-file-overwriting-target in clisp problems

Bug #1240624 reported by sds
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ASDF
Fix Released
Medium
Faré

Bug Description

This function has a special case for clisp:

  (defun rename-file-overwriting-target (source target)
    #+clisp ;; But for a bug in CLISP 2.48, we should use :if-exists :overwrite and be atomic
    (posix:copy-file source target :method :rename)
    #-clisp
    (rename-file source target
                 #+clozure :if-exists #+clozure :rename-and-delete))

This code causes build problems in clisp because when asdf is distributed with clisp, it is built before the posix module is available.
Also, nobody uses 2.48 anymore, so I think you can safely assume 2.49.

It would seem that a more portable (but not atomic) solution would be

(defun rename-file-overwriting-target (source target)
  #-clozure (when (probe-file target) (delete-file target))
  (rename-file source target
                 #+clozure :if-exists #+clozure :rename-and-delete))

Alternatively, the CLISP solution would be

#+clisp
(progn (require "syscalls")
             (funcall (find-symbol "COPY-FILE" "POSIX") source target :method :rename :if-exists :rename-and-delete))

Revision history for this message
Faré (fahree) wrote :

OK. Is there a simple way to detect whether the :if-exists :overwrite option is available?
If I try to use it on my Ubuntu 12.04.3 LTS's "GNU CLISP 2.49 (2010-07-07)", I get:

(posix:copy-file "/tmp/b" "/tmp/c" :method :rename :if-exists :overwrite)

*** - EVAL/APPLY: Too many arguments (4 instead of at most 2) given to RENAME-FILE

Changed in asdf:
assignee: nobody → Faré (fahree)
importance: Undecided → Medium
milestone: none → 3.0.3
status: New → Confirmed
Revision history for this message
Faré (fahree) wrote :

Also, when I started using this:
    #+clisp ;; in recent enough versions of CLISP, :if-exists :overwrite would make it atomic
    (progn (require "syscalls")
           (symbol-call :posix :copy-file source target :method :rename))
the asdf-pathname-test died with:
;; Loaded file /home/tunes/cl/asdf/test/test-asdf.asd
;;; 20131016T175450Z : CLISP 2.49+ (2010-07-17) (built on lux [127.0.0.1]) 3.0.2.26

*** - handle_fault error2 ! address = 0xccd05dee0 not in [0x3349c8000,0x334c8a1f0) !
SIGSEGV cannot be cured. Fault address = 0xccd05dee0.
GC count: 69
Space collected by GC: 68455336
Run time: 1 276079
Real time: 8 907945
GC time: 0 280019
Permanently allocated: 165312 bytes.
Currently in use: 5260080 bytes.
Free space: 1096036 bytes.

Sorry, no backtrace.

Revision history for this message
Faré (fahree) wrote :

(All other tests pass fine with this modification.)

Revision history for this message
sds (sds-gnu) wrote :

you can use arglist:

> (sys::arglist #'posix:copy-file)
(#:ARG0 #:ARG1 &KEY :METHOD :PRESERVE :IF-EXISTS :IF-DOES-NOT-EXIST)

but I suggest that you separate the two issues: whether IF-EXISTS works and my build problem.

thanks.

Revision history for this message
Faré (fahree) wrote :

To defeat clisp optimization, I actually had to use
  (funcall 'require "syscalls")
instead of
  (require "syscalls")
that allows me to build CLISP from hg, but somehow running its clisp binary still ends up invoking the system's CLISP.

Annoyingly, the new CLISP has the exact same version string as the previous one with a version date of "2010-07-17", though at least it doesn't segfault with version on the asdf-pathname-test:
   cd ~/cl/asdf
   make t l=clisp t=asdf-pathname-test.script
Now works!

Committed as 3.0.2.27

Changed in asdf:
status: Confirmed → Fix Committed
Revision history for this message
Faré (fahree) wrote :

I tried this:
    (progn
      (funcall 'require "syscalls")
      (let ((copy-file (find-symbol* :copy-file :posix)))
        (apply copy-file source target :method :rename
               (when (member :if-exists (sys::arglist copy-file)) '(:if-exists :overwrite)))))

But I get massive errors of this kind:
EVAL/APPLY: Too many arguments (4 instead of at most 2) given to RENAME-FILE

Revision history for this message
Faré (fahree) wrote :

Released in 3.0.3.

Changed in asdf:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.