如何使QuickLisp可用于从Shebang运行的脚本?

发布于 2025-02-08 22:37:43 字数 1085 浏览 1 评论 0原文

我最近一直在玩QuickLisp,并遇到了与Shebangs一起使用脚本的小问题。

设置

我进行了以下操作:

  1. 使用curl https://beta.quicklisp.org/quicklisp.lisp.lisp-o/tmp/quicklisp.lisp.lisp.lisp
  2. 下载了 QuickLisp。 )在环境中加载/tmp/QuickLisp时。
  3. 使用(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")

您可以找到我的愚蠢实验 there ,以及有问题的脚本

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:

  1. Downloaded quicklisp with curl https://beta.quicklisp.org/quicklisp.lisp -o /tmp/quicklisp.lisp
  2. Installed it with (quicklisp-quickstart:install) while having /tmp/quicklisp loaded in the environment.
  3. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ヅ她的身影、若隐若现 2025-02-15 22:37:43

在这种情况下,您需要:

(require :asdf)

TBH,我不知道为什么。 - 脚本等于- no-sysinit -no-userinit - disable-debugger - end-end-toplevel-options,所以我们忽略了很多。 (因此,加载QuickLisp的设置。LISP似乎也需要,因为您的.sbclrc不会加载它,这是QuickLisp添加此小片段的地方)

这是我在其他环境中所需的设置,例如CI。

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.

已下线请稍等 2025-02-15 22:37:43

我将使用Roswell - 使使用常见的LISP代码的独立脚本可用。

我描述了设置Roswell 在这里。这非常容易。
我描述了Roswell的全系统安装,或者如何在Ubuntu,Mac和Windows的本地安装Roswell。

或者,您也可以直接查找Roswell's site

使用Roswell将具有一个优势,您可以使用任何Roswell安装的通用LISP实现,这

Candidates impls for installation are:
abcl-bin
allegro
ccl-bin
clasp-bin
clasp
clisp
cmu-bin
ecl
mkcl
sbcl-bin
sbcl
sbcl-source

不仅是:单独使用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:

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 e.g. here:
https://roswell.github.io/Roswell-as-a-Scripting-Environment.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文