Reputation: 293
I wondered whether you could help with an error I'm getting with SBCL. I'm doing a tutorial, and one of the first lessons is to load a script into LISP. Here's the script, called hello.lisp:
(defun hello ()
"say hello to USER"
(format t "hello ~a" (uiop:getenv "USER")))
(hello)
But when I run the command: (load "hello.lisp") I get the following error:
debugger invoked on a SB-C::INPUT-ERROR-IN-LOAD in thread
#<THREAD "main thread" RUNNING {1000510083}>:
READ error during LOAD:
Package UIOP does not exist.
Line: 3, Column: 36, File-Position: 74
Stream: #<SB-INT:FORM-TRACKING-STREAM for "file /home/oliver/Programs/hello.lisp" {10015403F3}>
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [ABORT] Abort loading file "/home/oliver/Programs/hello.lisp".
1: Exit debugger, returning to top level.
(SB-C:COMPILER-ERROR SB-C::INPUT-ERROR-IN-LOAD :CONDITION #<SB-INT:SIMPLE-READER-PACKAGE-ERROR "Package ~A does not exist." {1001542543}> :STREAM #<SB-INT:FORM-TRACKING-STREAM for "file /home/oliver/Programs/hello.lisp" {10015403F3}>)
Any ideas on how I can fix? It seems I'm missing "UIOP" but I can't figure out how to install. Thanks in advance!
Oliver
Upvotes: 5
Views: 1291
Reputation: 26
SOLUTION Please! add this (require :asdf) command line to .sbclrc file It will work.
(require :asdf)
(defun hello ()
"say hello to USER"
(format t "hello ~a" (uiop:getenv "USER")))
(hello)
Upvotes: 1
Reputation: 21
hahaha is correct that the --script
command line option prevents SBCL from automatically loading ASDF and UIOP (among other things). This is because UIOP is part of ASDF, and ASDF is typically not loaded automatically. Very commonly ASDF is loaded when the user initialization file is loaded, as ASDF is needed by Quicklisp. Remember running (ql:add-to-init-file)
? SBCL's --script
option prevents loading the user initialization file (typically ~/.sbclrc
), thus none of these are loaded: Quicklisp, ASDF, UIOP.
--script filename
Implies --no-userinit --no-sysinit --disable-debugger --end-toplevel-options.
Batuhan Yamaner suggests (require :asdf)
, which works for me in SBCL, but this may not be portable across implementations. The ASDF Manual suggests (require "asdf")
. I don't know exactly why it would matter whether the argument to REQUIRE (or LOAD for that matter) is a string or symbol. As I read the HyperSpec it must be a string designator.
UIOP is part of ASDF 3, and any modern Common Lisp implementation will have all of UIOP available when you (require "asdf"). NB: (require :asdf) also works on all implementations but CLISP. Every implementation has sported ASDF 3 for years, and if yours only provides ASDF 2, we recommend you install ASDF 3 on top of it, using the facility in tools/install-asdf.lisp.
Upvotes: 1
Reputation: 51
(require :uiop)
it seems you're using the --script
option of sbcl which makes sbcl not load some stuff like asdf, uiop, etc.
Upvotes: 5