2
votes

My following code snippets will give SB-INT:SIMPLE-READER-PACKAGE-ERROR; I know it is because package "quicklisp-quickstart" is not defined yet while REPL reads the code; But the package IS defined in "quicklisp.lisp".

How can I make the following code work? Or How can I tell the common lisp reader this package will be defined in the dynamically loaded file?

* (let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
                                       (user-homedir-pathname))))
  (if (probe-file quicklisp-init)
    (load quicklisp-init)
    (progn
      (load "quicklisp.lisp")
      (quicklisp-quickstart:install))))

debugger invoked on a SB-INT:SIMPLE-READER-PACKAGE-ERROR in thread
#<THREAD "main thread" RUNNING {100299C6A3}>:
  Package QUICKLISP-QUICKSTART does not exist.

    Stream: #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDIN* {100017F893}>

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.
1
Are you having trouble installing the quicklisp ? If not, it'd be more informative to describe what you're trying to achieve and what steps you've taken. If yes, did you follow the quicklisp.org/beta step-by-step guide ?cybevnm
Maybe (eval (read-from-string "(quicklisp-quickstart:install)")).coredump
NB Quicklisp's setup page shows an example of doing exactly this, and it'll offer to add it to your .sbclrc or equivalent startup file on installing…BRPocock
I have no problem installing the quicklisp. I just want to load it, install it if not, during my application booting process.ll l

1 Answers

6
votes

You can use FIND-SYMBOL to try and find the function, and call it with FUNCALL. Something like

(let* ((package (find-package :quicklisp-quickstart))
       (function (unless (null package)
                   (find-symbol (string '#:install)
                                package))))
  (if (null function)
      (error "Can't install...")
      (funcall function)))