How do I build a standalone executable in SBCL? I've tried
; SLIME 2.20
CL-USER> (defun hullo ()
(format t "hullo"))
HULLO
CL-USER> (sb-ext:save-lisp-and-die "hullo" :toplevel #'hullo :executable t)
but that just produces the following error.
Cannot save core with multiple threads running.
Interactive thread (of current session):
#<THREAD "main thread" RUNNING {10019563F3}>
Other threads:
#<THREAD "Swank Sentinel" RUNNING {100329E073}>,
#<THREAD "control-thread" RUNNING {1003423A13}>,
#<THREAD "reader-thread" RUNNING {1003428043}>,
#<THREAD "swank-indentation-cache-thread" RUNNING
{1003428153}>,
#<THREAD "auto-flush-thread" RUNNING {1004047DA3}>,
#<THREAD "repl-thread" RUNNING {1004047FA3}>
[Condition of type SB-IMPL::SAVE-WITH-MULTIPLE-THREADS-ERROR]
What am I doing wrong?
What you are doing wrong is trying to save an image while multiple threads are running. Unlike many errors in Lisp the error message explains exactly what the problem is.
If you look up the function in the sbcl manual here then you find that indeed one may not save an image with multiple threads running. The extra threads come from swank (the CL half of SLIME). The manual says that you may add functions to *save-hooks* which destroy excess threads and functions to *init-hooks* to restore threads.
One way around all this is to not save the image when it is running through slime but instead to start sbcl directly at a terminal (note: no readline support), load your program and save from there.
Working with slime is different. In theory there is a SWANK-BACKEND:SAVE-IMAGE function but I’m not sure if that works. Also as saving an image kills the process you may want to fork (SB-POSIX:FORK) first, unless you are on Windows. But forking causes problems due to not being well specified and file descriptor issues (i.e. if you try fork->close swank connection->save and die then you may find that the connection in the parent process is closed (or worse, corrupted by appearing open but being closed at some lower level)). One can read about such things online. Note that due to the way sbcl threads are implemented, forking clones only the thread that forks and the other threads are not cloned. Thus forking and then saving should work but may cause problems when running the executable due to partial slime state.
You may be interested in buildapp.
If you want to be able to use slime with your saved application you can load swank and start listening on a socket or port (maybe with some command line argument) and then in Emacs you may connect to that swank backend with slime.
You have to run save-lisp-and-die from a new sbcl, not from Slime. Dan Robertson explains more.
It is cumbersome the first time, but you can put it in a Makefile and re-use it. Don't forget to load your dependencies.
build:
sbcl --load cl-torrents.asd \
--eval '(ql:quickload :torrents)' \
--eval '(use-package :torrents)' \ # not mandatory
--eval "(sb-ext:save-lisp-and-die #p\"torrents\" :toplevel #'main :executable t)"
The quickload implies Quicklisp is already loaded, which may be the case if you installed Quicklisp on your machine, because then your ~/.sbclr contains quicklisp loading script ((load quicklisp-init)).
However sb-ext is not portable across implementations. asdf:make is the cross-platform equivalent. Add this in your .asd system definition:
:build-operation "program-op" ;; leave as is
:build-pathname "<binary-name>"
:entry-point "<my-package:main-function>"
and then call asdf:make to build the executable.
You can have a look at buildapp (mentioned above), a still popular app to do just that, for SBCL and CCL. It is in Debian. http://lisp-lang.org/wiki/article/buildapp An example usage looks like
buildapp --output myapp \
--asdf-path . \
--asdf-tree ~/quicklisp/dists \
--load-system my-app \
--entry my-app:main
But see also Roswell, a more general purpose tool, also supposed to build executables, but it is less documented. https://roswell.github.io/
If you want to build an executable on a CI system (like Gitlab CI), you may appreciate a lisp Docker image which has already SBCL, others lisps and Quicklisp installed, and if you want to parse command line arguments, see https://lispcookbook.github.io/cl-cookbook/testing.html#gitlab-ci and (my) tutorial: https://vindarel.github.io/cl-torrents/tutorial.html#org8567d07
Related
I have a Windows 10 laptop where no TeX distribution was ever installed before (double-checked for config directories, files, and environment variables).
Wanting to install TeX Live 2021, I followed the full installation guide and also read the Windows-specific warnings. I've now tried several times, following different installation procedures - cleaning up everything (deleting base & user directories, environment variables, etc) before each time - but still don't manage to get a working installation. Before I report a bug at tex-live#tug, I wanted to ask for advice here, in case I'm doing something wrong. Here is what I did, step by step, and the problems I encountered in the process.
1. First I tried running the recommended online installer install-tl-windows.exe. It never got past the screen that tries to contact or load from a repository, even after a 30-min wait. Tried a dozen times, choosing different mirrors nearby and far away. No luck.
2. Then I downloaded and unpacked the install-tl.zip and run install-tl-windows.bat therein. This time the main installation window appeared. I left all default paths and environment variables (note that I do have write access to C:); in the selection scheme I unselected all languages except US & UK English, unselected XeTeX, LuaTeX, ConTeXt; also unselected TeXworks (I use Emacs), and clicked Install. After one to three hours (depending on the mirror I chose), the installation was complete.
I tried compiling a minimal latex document (see below), and got an error similar to the one in this old question:
I can't find the format file `pdflatex.fmt'
Following the advice in the answers to that question and similar questions elsewhere online such as this, I tried running texhash and fmtutil-sys --all. The latter gave the error
no appropriate script or programme found fmtutil.
for which there are also many posts online.
2a. Not understanding what the problem could be, I re-tried with all possible combinations of the following three options: (a) choosing different mirrors; (b) leaving the full selection of packages (ie without unselecting some languages, LuaTeX etc); (c) redoing the procedure by choosing "Run as Administrator". No luck.
3. At this point I tried downloading the ISO file with the full installation. Mounted the image and run install-tl-windows.bat (as normal user, as recommended; I repeat that I do have write access to C:). Everything proceeded as in step 2. above. At the end of the installation I tried running pdflatex on the minimal latex document. New error this time:
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021/W32TeX) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./minimal-template.tex
LaTeX2e <2020-10-01> patch level 4
L3 programming layer <2021-02-18>
! LaTeX Error: File `article.cls' not found.
Very strange. A file search revealed that article.cls is in the TeXLive file system; but kpathsea did not see it indeed.
4. At this point I opened the TeX Live Shell from the Start Menu; selected a CTAN mirror; updated the TL Manager which was not up to date; updated all packages; run Regenerate filename database; and run Regenerate formats. With the latter I got this error:
tex live shell:
mtutil [INFO]: total formats: 59
fmtutil [INFO]: exiting with status 53
C:\texlive\2021\bin\win32\runscript.tlu:915: command failed with exit code 53:
perl.exe c:\texlive\2021\texmf-dist\scripts\texlive\fmtutil.pl --sys --all
Here is a snip from the full set of errors appearing in the "Other" tab (I'm replacing my user directory with asterisks for privacy; note that I do have write access to these directories):
start load https://www.nic.funet.fi/pub/TeX/CTAN/systems/texlive/tlnet
finish load https://www.nic.funet.fi/pub/TeX/CTAN/systems/texlive/tlnet
start load http://contrib.texlive.info/current
finish load http://contrib.texlive.info/current
running mktexlsr ...
done running mktexlsr.
running mtxrun --generate ...
done running mtxrun --generate.
running updmap-sys ...
done running updmap-sys.
regenerating fmtutil.cnf in C:/texlive/2021/texmf-dist
running fmtutil-sys --byengine luatex --no-error-if-no-format --no-error-if-no-engine=luajithbtex,luajittex,mfluajit --status-file=C:\Users\***\AppData\Local\Temp\rPSb0Dpak2\WW_dJvUHgX ...
tlmgr.pl: fmtutil-sys --byengine luatex --no-error-if-no-format --no-error-if-no-engine=luajithbtex,luajittex,mfluajit --status-file=C:\Users\***\AppData\Local\Temp\rPSb0Dpak2\WW_dJvUHgX failed (status 255), output:
Unknown option: status-file
Try "fmtutil --help" for more information.
C:\texlive\2021\bin\win32\runscript.tlu:915: command failed with exit code 255:
perl.exe c:\texlive\2021\texmf-dist\scripts\texlive\fmtutil.pl --sys --byengine luatex --no-error-if-no-format --no-error-if-no-engine=luajithbtex,luajittex,mfluajit --status-file=C:\Users\***\AppData\Local\Temp\rPSb0Dpak2\WW_dJvUHgX
running fmtutil-sys --byengine luajithbtex --no-error-if-no-format --no-error-if-no-engine=luajithbtex,luajittex,mfluajit --status-file=C:\Users\***\AppData\Local\Temp\rPSb0Dpak2\WW_dJvUHgX ...
I tried to continue anyway with Regenerate fontmaps, and then tried again pdflatex on the minimal document. New error:
This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2021/W32TeX) (preloaded format=pdflatex)
restricted \write18 enabled.
---! c:/texlive/2021/texmf-var/web2c/pdftex/pdflatex.fmt made by different executable version
(Fatal format file error; I'm stymied)
5. I tried again steps 3. and 4., but with "Run as Administrator". Same errors.
OK at this point I give up and really don't know what to do. Am I doing something wrong? For the moment I have to concur with this post: installation of TeX Live 2021 is an utter failure.
Here is the minimal latex file I used for testing (copy & paste):
\documentclass{article}
\begin{document}
test
\section{Section}
test
\end{document}
Found, that the download is not working because the system path to "cmd.exe" is not found. Therefore: open a cmd window and add the system path prior to starting the .bat file (set PATH=%PATH%;C:\Windows\system32)
I am trying to get Common Lisp running on my Windows 10 machine and I have run into a problem with getting ASDF/(ql:quickload "...") to load a project. I generated the given project with the following command (after creating a C:\Users\ig88t\src\lisp folder):
(ql:quickload "quickproject")
(quickproject:make-project "~/src/lisp/swatchblade/" :depends-on '(vecto hunchentoot))
Which correctly generates the project and I can view the source at ~/src/lisp/swatchblade.
But I am unable to load it via
(ql:quickload "swatchblade")
Instead of loading, I get an error saying
System "swatchblade" not found [Condition of type
QUICKLISP-CLIENT:SYSTEM-NOT-FOUND]
I am going by two manuals, one that Xach wrote and another tailored for Windows. Xach recommends ~/.config/common-lisp/source-registry.conf.d/projects.conf whereas the second recommends ~/.config/common-lisp/source-registry.conf.d/asdf.conf. I am currently using the version Xach wrote as it has worked for me on Linux.
Going by the manual for ASDF it seems that ~/AppData/Local/ is where I should store .config/common-lisp/source-registry.conf.d/projects.conf. I have tried storing it at ~/AppData/Local/config/... as well as ~/AppData/Local/.config/... to no avail. I noticed that Clozure CL installs some quicklisp data in ~/AppData/Local/common-lisp, so I tried putting the source-registry.conf.d folder there as in ~/AppData/Local/common-lisp/source-registry.conf.d/projects.conf as well but it didn't work.
I have tried a lot of different variations of placing the folder in different places but I have not managed to figure out the right one. I would really appreciate any help/suggestions by anyone using Common Lisp and Quicklisp on Windows.
I am using Clozure CL, 1.11.5, and the wx86cl64 binary which comes with ASDF version 3.1.5 in case that matters.
--- edit ---
After talking with Xach about this issue, I tried:
(quickproject:make-project "~/quicklisp/local-projects/swatch"
:depends-on '(vecto hunchentoot))
and then ran:
(ql:register-local-projects)
but upon running:
(ql:quickload "swatch")
it failed yet again with:
System "swatch" not found [Condition of type
QUICKLISP-CLIENT:SYSTEM-NOT-FOUND]
He said it might be related to this PR for quickproject.
--- edit #2 ---
I recently tried using SBCL and things seemed to be working. I could create projects using quickproject and load them. Note that I am unable to load projects created with quickproject under CCL. However, when I restart slime/emacs, I am unable to load any projects previously created under SBCL.
; SLIME 2.20
CL-USER> (ql:quickload "quickproject")
To load "quickproject":
Load 1 ASDF system:
quickproject
; Loading "quickproject"
("quickproject")
CL-USER> (quickproject:make-project "~/quicklisp/local-projects/test/"
:depends-on '(vecto))
"test"
CL-USER> (ql:quickload "test")
To load "test":
Load 1 ASDF system:
test
; Loading "test"
[package test]
("test")
CL-USER>
--- intermission... restarting slime ---
; SLIME 2.20
CL-USER> (ql:quickload "test")
; Evaluation aborted on #<QUICKLISP-CLIENT:SYSTEM-NOT-FOUND {10034555B3}>.
CL-USER>
So I have no clue what could be causing the issue or how to resolve it, but it appears that creating/loading projects never works under Clozure CL and to works only within the current session in SBCL.
--- edit #3 ---
It seems I was wrong about SBCL. It seems that when I run
(quickproject:make-project "~/quicklisp/local-projects/test/"
:depends-on '(vecto))
It creates a folder in C:\Users\ig88t\AppData\Roaming\quicklisp\local-projects and not in C:\Users\ig88t\quicklisp\local-projects. It can load projects created within the current session as I said earlier, but is unable to find them in a new session.
(asdf::user-source-registry :direction :output)
Maxima for Windoows is compiled with SBCL but somehow is missing ASDF3 support. Here is the output of *FEATURES* from Maxima:
(QUICKLISP ASDF2 ASDF ASDF-UNICODE CL MK-DEFSYSTEM CLTL2 64-BIT
64-BIT-REGISTERS ALIEN-CALLBACKS ANSI-CL ASH-RIGHT-VOPS
C-STACK-IS-CONTROL-STACK COMMON-LISP COMPARE-AND-SWAP-VOPS COMPLEX-FLOAT-VOPS
CYCLE-COUNTER FLOAT-EQL-VOPS FP-AND-PC-STANDARD-SAVE GENCGC
IEEE-FLOATING-POINT INLINE-CONSTANTS INTEGER-EQL-VOP LINKAGE-TABLE
LITTLE-ENDIAN MEMORY-BARRIER-VOPS MULTIPLY-HIGH-VOPS OS-PROVIDES-DLOPEN
OS-PROVIDES-PUTWC PACKAGE-LOCAL-NICKNAMES PRECISE-ARG-COUNT-ERROR
RAW-INSTANCE-INIT-VOPS RAW-SIGNED-WORD SB-DOC SB-DYNAMIC-CORE SB-EVAL SB-FUTEX
SB-LDB SB-PACKAGE-LOCKS SB-QSHOW SB-SAFEPOINT SB-SAFEPOINT-STRICTLY
SB-SIMD-PACK SB-SOURCE-LOCATIONS SB-THREAD SB-THRUPTION SB-UNICODE SB-WTIMER
SBCL STACK-ALLOCATABLE-CLOSURES STACK-ALLOCATABLE-FIXED-OBJECTS
STACK-ALLOCATABLE-LISTS STACK-ALLOCATABLE-VECTORS
STACK-GROWS-DOWNWARD-NOT-UPWARD SYMBOL-INFO-VOPS UNBIND-N-VOP
UNDEFINED-FUN-RESTARTS UNWIND-TO-FRAME-AND-CALL-VOP WIN32 X86-64)
It must have picked-up QUICKLISP from my .sbclrc file and it actually can load some systems, like ALEXANDRIA. However, it fails to load the systems that involve more complex compilation, like LAPACK, MINPACK or ODEPACK. For example,
MAXIMA> (ql:quickload :uiop)
To load "uiop":
Load 1 ASDF system:
uiop
; Loading "uiop"
(:UIOP)
MAXIMA> (ql:quickload :lapack)
While evaluating the form starting at line 5, column 0
of #P"C:/Users/alexe_000/quicklisp/dists/quicklisp/software/f2cl-20170403-git/packages/lapack.asd":
Maxima encountered a Lisp error:
Error while trying to load definition for system lapack from pathname
C:/Users/alexe_000/quicklisp/dists/quicklisp/software/f2cl-20170403-git/packages/lapack.asd:
The name "F2CL-ASDF" does not designate any package.
Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
MAXIMA> (ql:quickload :f2cl-asdf)
To load "f2cl-asdf":
Load 1 ASDF system:
f2cl-asdf
; Loading "f2cl-asdf"
[package f2cl-asdf]
Maxima encountered a Lisp error:
The name "ASDF/COMPONENT" does not designate any package.
Comparing with features with my local SBCL installation, I tracked the problem down to ASDF3 being available on my SBCL, but not Maxima's.
I have managed to compile Maxima from sources on Linux and it works fine there. The compilation procedure on Windows is rather complicated and I would prefer to avoid it if I can. So, is there a way to make ASDF3 available somehow?
My Intent
I have an image generated by BitBake on which I'm interested in changing the window manager to metacity or maybe something similar.
My Process
I've added require recipes-graphics/images/core-image-x11.bb into my core recipe, which provides a simple Matchbox terminal window but seemingly no other functionality. If I add matchbox-desktop and matchbox-session-sato, it adds a bit more usability but not what I'm looking for.
I've included the default package from the metacity_2.34.13.bb recipe from the meta-gnome layer from the OpenEmbedded Metadata Index in the IMAGE_INSTALL variable of my core image. This installs several components including a metacity command in /usr/bin. If I run that command, I get the following message:
GLib-GIO-Message: Using the 'memory' GSettings backend. Your settings will not be saved or shared with other applications
(metacity:1124): GLib-GIO-ERROR **: Settings schema 'org.gnome.metacity' is not installed
Trace/breakpoint trap
I've navigated to /usr/share/glib-2.0/schemas and run glib-compile-schemas ., then run:
startx
metacity --replace
again. Now, the output is:
Window manager error: Unable to open X display
I haven't found a clear solution to this error which applies to my specific situation.
Update (2/29):
I may have now found a solution to this error, using these commands:
X&
export DISPLAY=:0
metacity&
At this point, I seem to be running something on one of my VTs. I can run demos like glxgears in that VT (glxgears is included in the mesa-demos recipe), but I don't know how to actually create a usable environment.
My question(s)
I'm not using much from meta-openembedded/meta-gnome (just metacity) or meta/recipes-gnome (adwaita-icon-theme, gnome-desktop3, gsettings-desktop-schemas and gtk+3), so am I missing some recipe which automates the addition of metacity?
(if not Question 1) How can I solve the error Window manager error: Unable to open X display?
The x11-common recipe adds a X session script that will run /usr/bin/x-session-manager: that is responsible for starting your desktop environment.
The way to implement a new session/DE in OE-Core is to use update-alternatives for "x-session-manager": see the matchbox-session recipe for the default implementation and mini-x-session recipe for an alternative.
mini-x-session might be modifiable for your needs so you don't need to write a new one: A /etc/mini_x/session file like this might do the trick:
# start any apps here, e.g. "my-desktop &"
exec metacity
Going from this (a running window manager) to "usable environment" might still be lots and lots of work, depending on your definition of usable.
I spent the afternoon trying to get the ritz-swank package to work with emacs and Clojure. (Googling the error message and much more gave no useful leads.) I hope somebody can give me some pointers that'll get me up and running.
The error is Symbol's value as variable is void: slime-ritz.
According to http://www.delorie.com/gnu/docs/elisp-manual-21/elisp_142.html:
"If you have never given a symbol any value as a global variable, we say that that symbol's global value is void. In other words, the symbol's value cell does not have any Lisp object in it. If you try to evaluate the symbol, you get a void-variable error rather than a value.... A void variable does not have any value."
I tried to find the value of slime-ritz, using Emacs 'describe-variable' (C-h v), but it didn't return anything. Doing an appropos search on "ritz" turned up nothing, but searching for "slime" returned bunches of functions (so I assume that the slime package is present).
My installation procedure
I followed the instructions in the Install section of https://github.com/pallet/ritz/tree/develop/swank (the pallet/ritz project page), starting from scratch twice to make sure I was doing things right. Here is the sequence of my last attempt:
Began with a system containing neither Emacs nor a ~/.emacs.d directory.
Installed Emacs 24.2, the latest available Mac OS X version (from http://emacsformacosx.com/)
Installed Emacs Prelude through a curl command (see http://batsov.com/prelude/)
Downloaded (as the project page said to) specific versions of slime and slime-ritz
Installed both of them manually using M-x package-install-file
Exited and relaunched emacs, just in case....
Installed lein-ritz as per the page's instructions and successfully got:
Greggs-Mac-Pro:combolock gr$ lein ritz
user=> Swank server listening on local port 51521
M-x slime-connect (which is supposed to make the connection from Emacs to the Swank server) returned the error Symbol's value as variable is void: slime-ritz in the Emacs minibuffer.
Diagnostic data
Running M-x package-activated-list produced the following list of loaded packages:
(ace-jump-mode ack-and-a-half elisp-slime-nav exec-path-from-shell expand-region flycheck gist gh guru-mode helm-projectile helm logito magithub magit melpa paredit pcache projectile dash rainbow-delimiters rainbow-mode s slime slime-ritz solarized-theme undo-tree volatile-highlights yasnippet zenburn-theme)
Running M-x package-list-packages listed the following packages as installed:
ace-jump-mode 20121104....
ack-and-a-half 20130204....
dash 20130223....
elisp-slime-nav 20130127....
exec-path-from-... 20121108.945
expand-region 20130223....
flycheck 20130223....
gh 20121231.208
gist 20121231.212
guru-mode 20121016....
helm 20130223....
helm-projectile 20130131....
logito 20120225....
magit 20130222....
magithub 20121130....
melpa 20120202....
paredit 20110508....
pcache 20120408....
projectile 20130220....
rainbow-delimiters 20120428.45
rainbow-mode 0.6
s 20130216....
slime 20101113.1 <-- manually installed, from sources
slime-ritz 0.6.0 <-- specified by pallet/ritz page
solarized-theme 20130215....
undo-tree 20130119.926
volatile-highli... 20120215.9
yasnippet 20130218....
zenburn-theme 20130215....
I noticed that clojure-mode wasn't present, so I added that, but step 8, above, gave the same error message.
Some shot-in-the-dark questions
1) Do I need to install pallet?
2) Do I need to install any other package from the ritz family (https://github.com/pallet/ritz)?
I'm really looking forward to using ritz-swank--it looks really powerful! (Thanks to Hugo Duncan for all the hard work!)
Emacs Predule ships nrepl.el instead of swank-clojure. You need to install nrepl-ritz instead of swank-ritz. Swank-clojure is a dead project, that's no longer supported in clojure-mode 2.0.0 (the one that comes with Predule).