Quicklisp: Manually add library to dist? - common-lisp

Some days ago I updated SBCL to 1.2.1 and I thought it couldn't hurt to update the quick lisp dist/client as well.
WRONG!
After firing up slime in Emacs, I got this error:
; caught ERROR:
; READ error during COMPILE-FILE:
;
; Symbol "CODE-TRACE-TABLE-OFFSET-SLOT" not found in the SB-VM package.
;
; Line: 1507, Column: 70, File-Position: 60197
;
; Stream: #<SB-SYS:FD-STREAM
; for "file /Users/fyi/quicklisp/dists/quicklisp/software/slime-2.7/swank-sbcl.lisp"
; {1008B07E43}>
;
; compilation unit aborted
; caught 1 fatal ERROR condition
; caught 1 ERROR condition
; printed 1 note
;;
;; Error while compiling /Users/fyi/quicklisp/dists/quicklisp/software/slime-2.7/swank-sbcl.lisp:
;; COMPILE-FILE returned NIL.
;; Aborting.
If you're using the quicklisp-slime-helper, so as I, the path to slime comes form the ~/quicklisp/dists/quicklisp/installed/systems/swank.txt file. Slime 2.8 should fix that error, but there is no quicklisp distribution that contains slime 2.8.
Coming down to my actual question. Is there a way to specify a library location outside of a quicklisp distribution? Or will I have to wait unit the next distribution has been made available and is there a guaranty a library will be updated in the next distribution?
I am sure I'm missing something, but the whole distribution stuff seems to me more of a hindrance than a help.

The next Quicklisp dist update is coming July 12 or 13. It will include a new SLIME that is compatible with SBCL 1.2.1. In the meantime, the easiest fix is to install SBCL 1.2.0.
Another option is to comment out the quicklisp-slime-helper lines in ~/.emacs and install slime according to its own procedure.

Related

Don't know how to require sb-cltl2

I'm trying to run an executable with an Hunchentoot server and I'm getting (after an unusual high CPU usage):
<INFO> [17:55:14] weblocks/server server.lisp (start) -
Starting weblocks WEBLOCKS/SERVER::PORT: 40001
WEBLOCKS/SERVER::SERVER-TYPE: :HUNCHENTOOT DEBUG: T
debugger invoked on a SB-INT:EXTENSION-FAILURE in thread
#<THREAD "main thread" RUNNING {1008C1EA13}>:
Don't know how to REQUIRE sb-cltl2.
Do you have any idea what's going on ? It works correctly on Slime where I use the start function.
(sbcl manual: http://www.sbcl.org/manual/#Customization-Hooks-for-Users)
In the main entry point, I try to capture the running thread so that I keep the server running on the foreground (my notes). This pattern worked with another clack-based web framework.
(defun start ()
(weblocks/debug:on)
(weblocks/server:start :port *port*))
(defun main ()
(defvar *port* (find-port:find-port))
(start)
(handler-case (bt:join-thread (find-if (lambda (th)
(search "hunchentoot" (bt:thread-name th)))
(bt:all-threads)))
(#+sbcl sb-sys:interactive-interrupt
#+ccl ccl:interrupt-signal-condition
#+clisp system::simple-interrupt-condition
#+ecl ext:interactive-interrupt
#+allegro excl:interrupt-signal
() (progn
(format *error-output* "Aborting.~&")
(uiop:quit 1))
;; for others, unhandled errors (we might want to do the same).
(error (c) (format t "Woops, an unknown error occured:~&~a~&" c)))))
Or any indication of what could be the cause ?
Thanks again.
(I'm using 40ants' weblocks:reblocks branch)
SBCL Debian 1.2.4
edit I tried
export SBCL_HOME=/usr/local/lib/sbcl/
I build with
build:
$(LISP) --quit \
--eval '(ql:quickload "foo")' \
--eval '(require :sb-cltl2)' \
--eval '(asdf:make :foo)'
=>
fatal error encountered in SBCL pid 25248(tid 140737353910016):
can't load .core for different runtime, sorry
Welcome to LDB, a low-level debugger for the Lisp runtime environment.
ldb>
The following environment failed:
export SBCL_HOME=/usr/local/lib/sbcl/
The error message tells us the following:
can't load .core for different runtime, sorry
Apparently the SBCL you ran used the given SBCL_HOME to find its core file, but failed due to the core being generated by different version SBCL.
A quick look at SBCL's source (starting from require) shows that the underlying function #'SB-INT:SBCL-HOMEDIR-PATHNAME is called to determine the installation path.
It looks like the one installed from the Debian package was installed in /usr/lib/sbcl/. The core file was easily found when starting Slime. You also had another version of SBCL in ~/.roswell/, but I guess you also ran ros install which installed it under /usr/local/lib/sbcl (/usr/local/ is for software that is not managed by the system).
Starting the roswell one when setting SBCL_HOME to the directory of the Debian one provoked the error about the incompatible core file (I guess).
What remains suprising is that (SB-INT:SBCL-HOMEDIR-PATHNAME) returns nil when starting your main function.

Cannot install lparallel alongside CL21 (?) Failing with CL21.CORE.FUNCTION

I have a weird mix of errors.
I was using CL21, I was in my package, and I wanted to install lparallel. Not possible:
(ql:quickload :lparallel)
To load "lparallel":
Load 1 ASDF system:
lparallel
; Loading "lparallel"
;
; caught ERROR:
; DYNAMIC-EXTENT on a weird thing: (CL21.CORE.FUNCTION:FUNCTION #:BODY-FN1)
;
; compilation unit aborted
; caught 2 fatal ERROR conditions
; caught 1 ERROR condition
; Evaluation aborted on #<UIOP/LISP-BUILD:COMPILE-FILE-ERROR {1008956C13}>.
I can reproduce it in a new session but it's a bit weird: if I quickload lparallel in cl-user, it complains on not finding the symbol CL21.CORE.FUNCTION, even if I didn't do nothing with CL21 yet:
The name "CL21.CORE.FUNCTION" does not designate any package.
So I ql:quickload CL21 and then on retrying to load lparallel. I get the first error.
But, I tried in Portacle for a fresh image and… I couldn't reproduce this.
Any idea ? Is that an issue with cl21, lparallel, quicklisp or asdf??
cl21 seems to replace the standard reader macro #' with its own version that isn't compatible with lparallel. When you tried to load lparallel in a fresh image, ASDF will load it from the .fasl-files that were compiled with cl21 loaded, so you must either delete those files or force recompilation with
(asdf:operate 'asdf:load-op :lparallel :force t)
Loading cl21 after lparallel is compiled with the standard language shouldn't cause the same problem.

How to properly save Common Lisp image using SBCL?

If I want to create a Lisp-image of my program, how do I do it properly? Are there any prerequisites? And doesn't it play nicely with QUICKLISP?
Right now, if I start SBCL (with just QUICKLISP pre-loaded) and save the image:
(save-lisp-and-die "core")
And then try to start SBCL again with this image
sbcl --core core
And then try to do:
(ql:quickload :cl-yaclyaml)
I get the following:
To load "cl-yaclyaml":
Load 1 ASDF system:
cl-yaclyaml
; Loading "cl-yaclyaml"
.......
debugger invoked on a SB-INT:EXTENSION-FAILURE in thread
#<THREAD "main thread" RUNNING {100322C613}>:
Don't know how to REQUIRE sb-sprof.
See also:
The SBCL Manual, Variable *MODULE-PROVIDER-FUNCTIONS*
The SBCL Manual, Function REQUIRE
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [RETRY ] Retry completing load for #<REQUIRE-SYSTEM "sb-sprof">.
1: [ACCEPT ] Continue, treating completing load for #<REQUIRE-SYSTEM "sb-sprof"> as having been successful.
2: Retry ASDF operation.
3: [CLEAR-CONFIGURATION-AND-RETRY] Retry ASDF operation after resetting the configuration.
4: [ABORT ] Give up on "cl-yaclyaml"
5: Exit debugger, returning to top level.
(SB-IMPL::REQUIRE-ERROR "Don't know how to ~S ~A." REQUIRE "sb-sprof")
0]
Alternatively, if I try:
(require 'sb-sprof)
when sbcl is started with saved core, I get the same error. If sbcl is started just as sbcl there is no error reported.
In fact, pre-loading QUICKLISP is not a problem: the same problem happens if sbcl is called initially with sbcl --no-userinit --no-sysinit.
Am I doing it wrong?
PS. If I use roswell, ros -L sbcl-bin -m core run somehow doesn't pick up the image (tested by declaring variable *A* before saving and not seeing it once restarted).
PS2. So far what it looks like is that sbcl does not provide extension modules (SB-SPROF, SB-POSIX, etc.) unless they are explicitly required prior saving the image.
Thanks for the help from #jkiiski here is the full explanation and solution:
SBCL uses extra modules (SB-SPROF, SB-POSIX and others) that are not always loaded into the image. These module reside in contrib directory located either where SBCL_HOME environment variable pointing (if it is set) or where the image resides (for example, in /usr/local/lib/sbcl/).
When an image is saved in another location and if SBCL_HOME is not set, SBCL won't be able to find contrib, hence the errors that I saw.
Setting SBCL_HOME to point to contrib location (or copying contrib to image location or new image to contrib location) solves the problem.
Finally, about roswell: roswell parameter -m searches for images in a specific location. For SBCL (sbcl-bin) it would be something like ~/.roswell/impls/x86-64/linux/sbcl-bin/1.3.7/dump/. Secondly, the image name for SBCL must have the form <name>.core. And to start it, use: ros -m <name> -L sbcl-bin run. (Quick edit: better use ros dump for saving images using roswell as it was pointed out to me)
If you want to create executables, you could try the following:
(sb-ext:save-lisp-and-die
"core"
:compression t
;; this is the main function:
:toplevel (lambda ()
(print "hell world")
0)
:executable t)
With this you should be able to call QUICKLOAD as you wish. Maybe you want to checkout my extension to CL-PROJECT for creating executables: https://github.com/ritschmaster/cl-project

Install GSLL on SBCL with Quicklisp

I am trying to install the GNU Scientific Library for Lisp (GSLL).
I saw there are answers to a similar question already, but I didn't find the connection to what is happening in my case.
Could anyone help to move on from here?
CL-USER> (lisp-implementation-type)
"SBCL"
CL-USER> (lisp-implementation-version)
"1.2.4.debian"
CL-USER> (ql:quickload "gsll")
; cc -m64 -I/lrde/home/alandi/quicklisp/dists/quicklisp/software/cffi_0.14.0/ -o /lrde/home/alandi/.cache/common-lisp/sbcl-1.2.4.debian-linux-x64/lrde/home/alandi/quicklisp/dists/quicklisp/software/cffi_0.14.0/libffi/libffi-unix /lrde/home/alandi/.cache/common-lisp/sbcl-1.2.4.debian-linux-x64/lrde/home/alandi/quicklisp/dists/quicklisp/software/cffi_0.14.0/libffi/libffi-unix.c
;
; compilation unit aborted
; caught 2 fatal ERROR conditions
To load "gsll":
Load 8 ASDF systems:
alexandria antik asdf-system-connections cffi-grovel
cffi-libffi metabang-bind osicat trivial-garbage
Install 1 Quicklisp gsll
release:
; Loading "gsll"
; cc -m64 -I/lrde/home/alandi/quicklisp/dists/quicklisp/software/cffi_0.14.0/ -o /lrde/home/alandi/.cache/common-lisp/sbcl-1.2.4.debian-linux-x64/lrde/home/alandi/quicklisp/dists/quicklisp/software/cffi_0.14.0/libffi/libffi-unix /lrde/home/alandi/.cache/common-lisp/sbcl-1.2.4.debian-linux-x64/lrde/home/alandi/quicklisp/dists/quicklisp/software/cffi_0.14.0/libffi/libffi-unix.c
;
; compilation unit aborted
; caught 2 fatal ERROR conditions
; Evaluation aborted on Component "gsll" not found.
I am on OS X, but maybe this helps you anyway. I could load the lib by (ql:quickload "gsll") but I had to make an adjustment:
The path to GSLs dynamic libraries is found by a shell call gsl-config --prefix.
For me this call returns /usr/local/Cellar/gsl/1.16 but my dynlibs are located in /usr/local/Cellar/gsl/1.16/lib. So I just had to make some adjustments to the pathnames in the file ~/quicklisp/dists/quicklisp/software/gsll-20140211-git/init/init.lisp.
Seach for (cffi:define-foreign-library libgslcblas ...) and (cffi:define-foreign-library libgsl ...) and adjust your paths there.
Maybe that helps.

Unable to load sdl-gfx in quicklisp

I've been installing lispbuilder-sdl family with quicklisp and encountered error in sdl-gfx:
CL-USER> (ql:quickload "lispbuilder-sdl-gfx")
To load "lispbuilder-sdl-gfx":
Load 1 ASDF system:
lispbuilder-sdl-gfx
; Loading "lispbuilder-sdl-gfx"
...........;
; compilation unit aborted
; caught 1 fatal ERROR condition
Unable to load any of the alternatives:
("libSDL_gfx.dylib" (:FRAMEWORK "SDL_gfx"))
[Condition of type CFFI:LOAD-FOREIGN-LIBRARY-ERROR]
I use slime+emacs+SBCL under macosx 10.6. I've installed SDL.framework from this link:
http://thirdcog.eu/apps/frameworks#glew
a file called sdl_with_friends.zip and put things under /Library/Frameworks. However it still complains about cannot find framework.
Any idea on this?
The easiest way to install lispbuilder-sdl on Mac OSX is to fire up SBCL and use Quicklisp:
(ql:quickload "lispbuilder-sdl")
It will probably fail, but you can then compile the OS-X specific helper library located in "~quicklisp/dists/quicklisp/software/lispbuilder-20110619-svn/lispbuilder-sdl/cocoahelper"; just cd to this directory and type "make"
To verify that worked, try this:
(ql:quickload "lispbuilder-sdl-examples")
(lispbuilder-sdl-examples:bezier)
Another common gotcha is when you are using Emacs / SLIME. The cocoa bits must run on the primary thread, so you have to invoke things like this:
#+darwin #+sb-thread
(let ((thread (first (last (sb-thread:list-all-threads)))))
(sb-thread:interrupt-thread thread #'(lambda () (ql:quickload "lispbuilder-sdl-examples")))
(sb-thread:interrupt-thread thread #'(lambda () (lispbuilder-sdl-examples:bezier))))
The error is complaining that it can't load the dynamic library for SDL. I'm sorry - I don't know much about the directory layout on macs (which appears to be where you're working), so I can't exactly tell you how to fix this. But somewhere you should have installed a file called libSDL_gfx.dylib (probably this extension) and the error message means that CFFI is failing to find it.
using homebrew you can brew install sdl_gfx

Resources