I am currently have a small program in Common Lisp, which I want to run as a shell script. I am using the SBCL and perfectly fine with this so will prefer to stay on this platform. :)
I am aware about the --script
option and it works flawlessly except for (ql:quickload)
form.
My program uses the CL-FAD, which loads through ql:quickload
(I think I should mention that it is package-loading function from quicklisp). When script runs up to evaluating the
(ql:quickload :cl-fad)
form, it breaks with the next error:
package "QL" not found
Program is packed in the single source file, which has following header:
(defpackage :my-package
(:use :common-lisp)
(:export :my-main-method))
It is simple automation executable, so I decided (maybe erroneously) not to write any ASDF system. It exports single function which should be run without any arguments.
For this program I am currently trying to write the launcher script, and this is what I am staring at:
#!/usr/bin/sbcl --script
(load "my-program.lisp")
(in-package :my-package)
(my-main-method)
This three lines (not counting the shebang) is what I am want to automate. As I read in documentation, script with this shebang can be called as simple ./script.lisp
, and it really does this... with the error described before.
What I need to add in the launcher for :cl-fad
to load properly? Documentation states that with --script
option SBCL doesn't load any init file, so do I really need to copypaste the lines
#-quicklisp
(let ((quicklisp-init (merge-pathnames "systems/quicklisp/setup.lisp"
(user-homedir-pathname))))
(when (probe-file quicklisp-init)
(load quicklisp-init)))
(which ql:add-to-init-file
adds to .sbclrc), to my launcher script?
Maybe I have some deep architectural flaw in my program setup?
And yes, when I enter the lines which I try to automate in REPL in the sbcl itself, program runs as expected.