3

I'm using ASDF load cl-ppcre in a script file. The issue is (progn (require :asdf) (require :cl-ppcre)) is perfectly fine in a top level, but if the same codes wrapped in a handler-case, a system-out-of-date condition will be caught by handler-case and the whole evaluation stops, and required packages won't be loaded. I just confirm the same issue also happens in a REPL. No matter what library I try to load, the same issue just happen in a handler-case. The following is a complete session:

; SLIME 2.27
CL-USER> (require :asdf)
NIL
CL-USER> (find-package :cl-ppcre)
NIL
CL-USER> (handler-case (require :cl-ppcre) (t (c) (format t "~a: ~a~%" (type-of c) c)))
SYSTEM-OUT-OF-DATE: system cl-ppcre is out of date
NIL
CL-USER> (find-package :cl-ppcre)
NIL
CL-USER> (require :cl-ppcre)
NIL
CL-USER> (find-package :cl-ppcre)
#<PACKAGE "CL-PPCRE">
CL-USER> (handler-case (require :cl-ppcre) (t (c) (format t "~a: ~a~%" (type-of c) c)))
NIL
CL-USER> (list (lisp-implementation-type) (lisp-implementation-version))
("SBCL" "2.2.4")
CL-USER> (asdf:asdf-version)
"3.3.1"
CL-USER> (directory "/home/pxie/common-lisp/*" :resolve-symlinks nil)
(#P"/home/pxie/common-lisp/alexandria/" #P"/home/pxie/common-lisp/cl-ppcre/")

According to ASDF manual, I put my libraries in ~/common-lisp directory, and the libraries already compiled and saved in the ~/.cache/common-lisp directory.

Any insight of what is going on in ASDF?

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
xiepan
  • 623
  • 4
  • 13
  • what does 'out of date' mean? Probably: there are "newer" source files than the compiled files? Maybe: there are newer source files than the ones the system was compiled from? – Rainer Joswig May 22 '22 at 09:59
  • TLDR; instead of catching `t`, catch `error`: (handler-case … (error (c) … ))`. – Ehvince Jun 23 '22 at 22:44

1 Answers1

5

If you ask handler-case to catch any condition that is signalled, as you have done, it will do that, whether or not the condition is an error. You almost never want to do that.

In particular if you look at plan.lisp in the ASDF sources you will find

  ;; NB: This is not an error, not a warning, but a normal expected condition,
  ;; to be to signaled by FIND-SYSTEM when it detects an out-of-date system,
  ;; *before* it tries to replace it with a new definition.
  (define-condition system-out-of-date (condition)
    ...)
ignis volens
  • 7,040
  • 2
  • 12
  • 3
    It is much more reasonable to handle only `error` conditions - and even then, it's better to be as specific as possible. – Xach May 22 '22 at 15:53
  • 3
    @Xach yes. In fact I think that `(handler-case (t ...))` is *never* safe because you just have no idea what is going on with conditions, and `handler-case` unwinds the stack. `handler-bind` *could* be safe if your handlers decline the condition. – ignis volens May 22 '22 at 15:56