如何使QuickLisp可用于从Shebang运行的脚本?
我最近一直在玩QuickLisp,并遇到了与Shebangs一起使用脚本的小问题。
设置
我进行了以下操作:
- 使用
curl https://beta.quicklisp.org/quicklisp.lisp.lisp-o/tmp/quicklisp.lisp.lisp.lisp
- 下载了 QuickLisp。 )在环境中加载
/tmp/QuickLisp
时。 - 使用
(ql:add-to-Init-file)添加了QuickLisp,
需要QuickLisp(特别是ASDF)的脚本问题
,我可以使用sbcl -load〜/运行它。 quicklisp/setup.lisp -script start.lisp
很好。但是,当我将其作为独立脚本运行时,带有Shebang /usr/bin/env sbcl -script
时,它失败了,错误地说它找不到之类的东西。 uiop
等。除非我将以下两行放在脚本本身中:
(load "~/quicklisp/setup.lisp")
(ql:quickload "asdf")
ps:任何指针都会有所帮助。
pps:我敢肯定这是一个愚蠢的错误,请原谅我。
I've been playing around with Quicklisp lately, and have this minor problem working with scripts with Shebangs.
Setup
I did the following:
- Downloaded quicklisp with
curl https://beta.quicklisp.org/quicklisp.lisp -o /tmp/quicklisp.lisp
- Installed it with
(quicklisp-quickstart:install)
while having/tmp/quicklisp
loaded in the environment. - Added Quicklisp to init file using
(ql:add-to-init-file)
Problem
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在这种情况下,您需要:
TBH,我不知道为什么。
- 脚本
等于- no-sysinit -no-userinit - disable-debugger - end-end-toplevel-options
,所以我们忽略了很多。 (因此,加载QuickLisp的设置。LISP似乎也需要,因为您的.sbclrc不会加载它,这是QuickLisp添加此小片段的地方)这是我在其他环境中所需的设置,例如CI。
In that case you need:
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.
我将使用
Roswell
- 使使用常见的LISP代码的独立脚本可用。我描述了设置
Roswell
在这里。这非常容易。我描述了Roswell的全系统安装,或者如何在Ubuntu,Mac和Windows的本地安装Roswell。
或者,您也可以直接查找
Roswell
's site 。使用Roswell将具有一个优势,您可以使用任何Roswell安装的通用LISP实现,这
不仅是:单独使用
SBCL
。罗斯威尔允许在通用LISP写入外壳时直接从外壳呼叫的脚本。
从内部Roswell
$ ROS ...
命令,可以使用QuickLisp。因此,$ ros install xxx
通常使用quicklisp来安装xxx
。使用Roswell,您可以通过单个命令(包括您的脚本)从bash中collable collable collewell。
在这里看:
https://roswell.github.io/Roswell-as-a-脚本 - 环境.html
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:
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 installxxx
.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 e.g. here:
https://roswell.github.io/Roswell-as-a-Scripting-Environment.html