在 Docker 容器中加载 Lisp 文件时出现“参数数量错误”错误

问题描述 投票:0回答:1

我尝试在 Docker 容器中使用

(load "myprogram.lisp")
命令加载 Lisp 文件,但遇到以下错误:

error in process filter: Wrong number of arguments: (output &optional target), 3

这是“myprogram.lisp”的内容:

(defun hello-lisp ()
  (format t "Hello, Lisp!~%"))

(hello-lisp)

地点:

/home/user/src/myprogram.lisp

我在具有以下 Dockerfile 内容的 Docker 容器内运行此代码:

FROM ubuntu:latest

# Set non-interactive mode for apt-get
ENV DEBIAN_FRONTEND=noninteractive

# Create a non-root user named "user"
RUN useradd -ms /bin/bash user

# Update the package list
RUN apt-get update

# Install necessary packages, including bzip2 and make
RUN apt-get install -y \
    git \
    curl \
    bzip2 \
    sudo \
    make \
    zlib1g-dev \
    emacs

# grant sudo rights to `user`
RUN echo "user:user" | chpasswd && adduser user sudo

# Clean up after package installation
RUN rm -rf /var/lib/apt/lists/*

# Allow the "user" to run sudo without a password and disable TTY requirement
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/user-nopasswd
RUN echo "Defaults !requiretty" >> /etc/sudoers

# Clone your .emacs.d configuration from your GitHub repository as the "user"
USER user
WORKDIR /home/user
RUN git clone https://github.com/gwangjinkim/.emacs.d.git /home/user/.emacs.d

# Download Roswell
RUN curl -sOL $(curl -s https://api.github.com/repos/roswell/roswell/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep 'roswell_' | grep 'amd64.deb')

# Install Roswell
RUN sudo dpkg -i roswell*.deb
RUN rm roswell*.deb

# Update Roswell
RUN ros update

# Set up Roswell's environment variables
ENV PATH=$PATH:/home/user/.roswell/bin

# Install SLIME using Roswell
RUN ros install slime

# Expose the port for SLIME if needed
# EXPOSE 4005

# Start Emacs as the "user"
CMD emacs

我不确定为什么 Docker 容器中会发生此错误。文件“myprogram.lisp”包含有效的 Lisp 代码,并且我在容器内使用标准 Lisp 环境。我检查了文件路径,它是正确的。我使用 SBCL 作为我的 Lisp 解释器。

docker emacs dockerfile common-lisp slime
1个回答
0
投票

问题来自于swank的版本(sbcl中安装的common lisp代码,emacs端的slime使用它从当前sbcl图像中获取信息)与slime版本不对应

当我使用 Dockerfile 创建映像时,我运行 emacs,然后调用

M-x slime
,这给了我以下错误消息:

Versions differ: 2.26.1 (slime) vs. 2.28 (swank). Continue? (y or n)

当你在 emacs 中调用 slime 时,它会尝试自动安装 swank 部分。所以你不必使用 roswell 来安装 swank :让 slime 安装正确版本的 swank。

要更正错误并使您的容器/emacs/slime/sbcl 协同工作并正确加载 myprogram.lisp,请执行以下操作:

从 Dockerfile 中删除以下行:

# Install SLIME using Roswell
RUN ros install slime

注释掉 ~/.emacs.d/myinit.el 文件的第 275 行:

;; (load (expand-file-name "~/.roswell/helper.el"))

然后使用 Dockerfile 重建图像

podman build -t scratch .

然后使用您的图像运行一个容器(这会启动 emacs):

podman run -it --rm localhost/scratch:latest

在 emacs 中,键入

M-x slime RET
,然后键入
C-c C-l
加载 myprogram.lisp 文件。现在应该可以工作了。

© www.soinside.com 2019 - 2024. All rights reserved.