I've been playing around with Quicklisp lately, and have this minor problem working with scripts with Shebangs.
I did the following:
curl https://beta.quicklisp.org/quicklisp.lisp -o /tmp/quicklisp.lisp
(quicklisp-quickstart:install)
while having /tmp/quicklisp
loaded in the environment.(ql:add-to-init-file)
For a script that needs Quicklisp (specifically ASDF), I can run it with sbcl --load ~/quicklisp/setup.lisp --script start.lisp
just fine. However, when I run it as a standalone script with the Shebang /usr/bin/env sbcl --script
, it fails with an error saying that it isn't able to find things like UIOP
, etc. unless I place the below two lines in the script itself:
(load "~/quicklisp/setup.lisp")
(ql:quickload "asdf")
You can find my stupid experiment here , and the script in question here .
PS: Any pointers would be really helpful.
PPS: I'm sure it's a stupid mistake on my end, forgive me.
In that case you need:
(require :asdf)
TBH, I don't know exactly why. --script
equals to --no-sysinit --no-userinit --disable-debugger --end-toplevel-options
, so it's a lot we ignore. (thus loading quicklisp's setup.lisp seems required too, because it won't be loaded by your .sbclrc, which is where Quicklisp adds this little snippet)
It's a setting I have needed in other environments, such as a CI.
I would use roswell
- which makes standalone scripts available which use Common Lisp code.
I described setting up roswell
here . It is super easy. I describe there system-wide installation of roswell or also how to locally install roswell in ubuntu, mac and windows.
Or you could also directly lookup on roswell
's site .
Using roswell would have the advantage that you can use any roswell-installable Common Lisp implementations, which are:
Candidates impls for installation are:
abcl-bin
allegro
ccl-bin
clasp-bin
clasp
clisp
cmu-bin
ecl
mkcl
sbcl-bin
sbcl
sbcl-source
not only sbcl
alone.
And roswell allows scripts which are call-able directly from the shell while written in Common Lisp.
From inside roswell $ ros ...
commands , quicklisp is available. So $ ros install xxx
uses usually quicklisp to install xxx
.
Using roswell, you can make any Common Lisp program callable from the bash by a single command - including your script - written in common lisp.
Look at eg here: https://roswell.github.io/Roswell-as-a-Scripting-Environment.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.