【问题标题】:How to properly use cxml/klacks library with quicklisp (and sbcl)?如何正确使用带有 quicklisp(和 sbcl)的 cxml/klacks 库?
【发布时间】:2020-11-03 09:31:15
【问题描述】:

概述 我正在尝试运行this code 的简化版本,它需要cxmlklacks 库来进行XML 解析。 (具体代码为"The Art of Postgresql"本书第47章。) 由于我对(Common) Lisp/ASDF/Quicklisp知之甚少,所以不知道如何正确安装所需的cxml/klacks库。

系统 万一这很重要,我在 Ubuntu 下使用 SBCL 1.5.5.debian(作为记录,我之前尝试过 clisp,但我发现它带有一个非常过时的 ASDF 版本。)

到目前为止我已完成的步骤

在 bash 中:

sudo apt-get install cl-cxml

(确实 /usr/share/common-lisp/source/cxml//usr/share/common-lisp/source/cxml/klacks/ 现在出现在我的系统上。)

在 sbcl REPL 中:

(ql:quickload :cxml)

结果:一条很长的错误消息,其要点似乎是Component "cxml/dom" not found。 (尽管/usr/share/common-lisp/source/cxml/dom 确实存在,但我不确定它是否重要。)请参阅最后的完整错误消息。

(ql:quickload :klacks)

结果:另一个长错误,其要点是System "klacks" not found(即使该目录再次出现在系统上)。

备注

qucikload 用于其他库作品,例如:

(ql:quickload :postmodern)
(ql:quickload :zip)
(ql:quickload :yason)

问题

简而言之:在上述系统上安装cxmlklacks 的正确方法是什么?

除了这个具体问题的解决方案,我想更好地了解发生了什么,特别是:

  • 是否可以使用quicklisp 安装所有依赖项,或者是否有一些支持它而一些不支持? (在这种情况下,cxml 是不支持 quicklisp 的依赖项吗?我怎么知道哪些包支持它?)

  • quciklisp 是否查看本地安装(即/usr/share/common-lisp/source/cxml/),还是仅从在线存储库中工作? (换句话说:我通过 apt-get 安装 cl-xml 是否重要?)

  • 如果考虑到本地路径,那为什么找不到cxml/domcxml/klacks

  • 既然klackscxml的子包,那我需要单独导入吗? 通过浏览提到的源代码,尤其是package.lisppubnames.asd,我没有看到它显式导入。它仍然在代码中使用,例如here。所以我想需要的是显式导入cxml,然后所有子包(包括klacks)也被导入,自动加上正确的命名空间前缀?

详细的错误信息

* (ql:quickload :cxml)
;;; Checking for wide character support... WARNING: Lisp implementation doesn't use UTF-16, but accepts surrogate code points.
 yes, using code points.
To load "cxml":
  Load 1 ASDF system:
    cxml
; Loading "cxml"
;;; Checking for wide character support... WARNING: Lisp implementation doesn't use UTF-16, but accepts surrogate code points.
 yes, using code points.
.
;;; Checking for wide character support... WARNING: Lisp implementation doesn't use UTF-16, but accepts surrogate code points.
 yes, using code points.
;;; Checking for wide character support... WARNING: Lisp implementation doesn't use UTF-16, but accepts surrogate code points.
 yes, using code points.
;;; Building Closure with CHARACTER RUNES
To load "cxml/dom":
  Load 3 ASDF systems:
    closure-common puri trivial-gray-streams
  Install 1 Quicklisp release:
    cxml
; Loading "cxml/dom"
;;; Checking for wide character support... WARNING: Lisp implementation doesn't use UTF-16, but accepts surrogate code points.
 yes, using code points.
.
debugger invoked on a ASDF/FIND-COMPONENT:MISSING-COMPONENT in thread
#<THREAD "main thread" RUNNING {10005504C3}>:
  Component "cxml/dom" not found

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [RETRY                        ] Retry ASDF operation.
  1: [CLEAR-CONFIGURATION-AND-RETRY] Retry ASDF operation after resetting the
                                     configuration.
  2:                                 Retry ASDF operation.
  3:                                 Retry ASDF operation after resetting the
                                     configuration.
  4: [ABORT                        ] Give up on "cxml/dom"
  5:                                 Give up on "cxml"
  6:                                 Exit debugger, returning to top level.

((:METHOD ASDF/OPERATE:OPERATE (SYMBOL T)) ASDF/LISP-ACTION:LOAD-OP "cxml/dom" :VERBOSE NIL) [fast-method]
   error finding frame source: Bogus form-number: the source file has probably
                               changed too much to cope with.
   source: NIL
0]

* (ql:quickload :klacks)

debugger invoked on a QUICKLISP-CLIENT:SYSTEM-NOT-FOUND in thread
#<THREAD "main thread" RUNNING {10005504C3}>:
  System "klacks" not found

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [CONTINUE] Try again
  1: [ABORT   ] Give up on "klacks"
  2:            Exit debugger, returning to top level.

((LABELS QUICKLISP-CLIENT::RECURSE :IN QUICKLISP-CLIENT::COMPUTE-LOAD-STRATEGY) "klacks")
   source: (CERROR "Try again" 'SYSTEM-NOT-FOUND :NAME NAME)

【问题讨论】:

  • 我强烈怀疑您的 SBCL 太旧了,您应该尝试使用当前的。

标签: xml common-lisp sbcl quicklisp asdf


【解决方案1】:

由于您可以加载其他系统,我假设您已经在您的系统上设置了 quicklisp。

quicklisp 上没有名为“klacks”的包。

您可以通过运行来检查:

(ql:system-apropos "klacks")

哪些输出:

#<SYSTEM cxml-klacks / cxml-20181018-git / quicklisp 2019-03-07>
#<SYSTEM cxml/klacks / cxml-20181018-git / quicklisp 2019-03-07>
#<SYSTEM fxml/klacks / fxml-20181210-git / quicklisp 2019-03-07>

所以你要找的系统是cxml-klacks

加载它使用:

(ql:quickload "cxml-klacks")

加载正常。我的系统上的输出:

To load "cxml-klacks":
  Load 1 ASDF system:
    cxml-klacks
; Loading "cxml-klacks"
;;; Checking for wide character support... yes, using code points.
;;; Checking for wide character support... yes, using code points.
;;; Building Closure with CHARACTER RUNES

("cxml-klacks")

另外,cxml 在我的系统上加载正常,但我使用的是 Clozure CL,我不确定该错误对你来说是什么。尝试加载 cxml-klacks 看看是否适合您。

您也可以尝试加载cxml/klacks,这可能是您想要的包。

【讨论】:

  • 感谢您的提示:(ql:system-apropos "klacks") 返回的结果与您的相同(尽管时间戳较新),但 (ql:quickload "cxml-klacks")(ql:quickload "cxml/klacks") 均失败(原因似乎是 Component "cxml/klacks" not found)。
  • > 我假设你已经在你的系统上设置了 quicklisp 是的,还有一些其他的包(比如postmodernzip,...)它工作正常。
  • 认为你需要先完成安装cxml。这让 cxml/dom 窒息。
  • 您可以尝试使用最新版本的 sbcl 吗?来自主页:最新版本是 SBCL 2.0.6,于 2020 年 6 月 29 日发布。
【解决方案2】:

最重要的是你的系统中已经安装了quicklisp

请关注here的灰框内的安装。

简而言之,就是:

# in mac:
$ curl -O https://beta.quicklisp.org/quicklisp.lisp
# or in linux do:
$ wget https://beta.quicklisp.org/quicklisp.lisp
# in windows download manually https://beta.quicklisp.org/quicklisp.lisp

# $ curl -O https://beta.quicklisp.org/quicklisp.lisp.asc # this I leave out
# $ gpg --verify quicklisp.lisp.asc quicklisp.lisp

# start SBCL
$ sbcl --load quicklisp.lisp # path to the downloaded quicklisp.lisp!

# in SBCL REPL install quicklisp by:
* (quicklisp-quickstart:install)

# it says:
#   ==== quicklisp installed ====
# 
#     To load a system, use: (ql:quickload "system-name")
# 
#     To find systems, use: (ql:system-apropos "term")# 
# 
#     To load Quicklisp every time you start Lisp, use: (ql:add-to-init-file)
# 
#     For more information, see http://www.quicklisp.org/beta/
# 

# test by installing vecto package:
* (ql:system-apropos "vecto")

; Fetching #<URL "http://beta.quicklisp.org/dist/quicklisp/2010-10-07/systems.txt">
; 45.30KB
==================================================
46,386 bytes in 0.50 seconds (89.70KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/dist/quicklisp/2010-10-07/releases.txt">
; 83.49KB
==================================================
85,490 bytes in 0.53 seconds (157.22KB/sec)
#<SYSTEM cl-vectors / cl-vectors-20101006-git / quicklisp 2010-10-07>
#<SYSTEM lispbuilder-sdl-cl-vectors / lispbuilder-20101006-svn / quicklisp 2010-10-07>
#<SYSTEM lispbuilder-sdl-cl-vectors-examples / lispbuilder-20101006-svn / quicklisp 2010-10-07>
#<SYSTEM lispbuilder-sdl-vecto / lispbuilder-20101006-svn / quicklisp 2010-10-07>
#<SYSTEM lispbuilder-sdl-vecto-examples / lispbuilder-20101006-svn / quicklisp 2010-10-07>
#<SYSTEM static-vectors / static-vectors-20101006-git / quicklisp 2010-10-07>
#<SYSTEM vecto / vecto-1.4.3 / quicklisp 2010-10-07>
NIL

# load it:
* (ql:quickload "vecto")
To load "vecto":
  Install 5 Quicklisp releases:
    cl-vectors salza2 vecto zpb-ttf zpng
; Fetching #<URL "http://beta.quicklisp.org/archive/salza2/2010-10-06/salza2-2.0.7.tgz">
; 14.84KB
==================================================
15,197 bytes in 0.12 seconds (125.77KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/zpng/2010-10-06/zpng-1.2.tgz">
; 38.59KB
==================================================
39,521 bytes in 0.37 seconds (103.47KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/zpb-ttf/2010-10-06/zpb-ttf-1.0.tgz">
; 42.59KB
==================================================
43,611 bytes in 0.39 seconds (110.33KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/cl-vectors/2010-10-06/cl-vectors-20101006-git.tgz">
; 40.40KB
==================================================
41,374 bytes in 0.37 seconds (109.20KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/vecto/2010-10-06/vecto-1.4.3.tgz">
; 75.71KB
==================================================
77,526 bytes in 0.49 seconds (153.57KB/sec)
; Loading "vecto"
..................................................
[package zpb-ttf].................................
[package salza2]..................................
[package zpng]....................................
[package net.tuxee.paths].........................
[package net.tuxee.aa]............................
[package net.tuxee.aa-bin]........................
[package net.tuxee.vectors].......................
[package vecto]........
("vecto")

# highly recommended - do:
* (ql:add-to-init-file)

# this will give:

I will append the following lines to #P"/Users/quicklisp/.sbclrc":

  ;;; The following lines added by ql:add-to-init-file:
  #-quicklisp
  (let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
                                         (user-homedir-pathname))))
    (when (probe-file quicklisp-init)
      (load quicklisp-init)))

Press Enter to continue. # do that!


#P"/Users/quicklisp/.sbclrc"
* (quit)
$ 

最后一步将 quicklisp 的 setup.lisp 的加载命令添加到 .sbclrc 。将其添加到您使用的实现的任何配置文件中,例如对于clisp,将其添加到~/.clisp,如果没有,则创建。

安装时让它安装到主文件夹(~/quicklisp)。 所以那个路径是~/quicklisp/setup.lisp。 在 sbcl 中,您可以通过 (load "~/quicklisp/setup.lisp") 启动 quicklisp。 如果没有将此加载命令添加到您的 ~/.sbclrc 文件中。

安装/导入 klacks:

(ql:quickload :cxml)

;; then use it by:
(klacks:<klacks-function> <args>)

;; it is one of the few packages, where you install by another name
;; but then have several names available for sub-packages!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-23
    • 1970-01-01
    • 2016-01-05
    • 2020-03-13
    • 1970-01-01
    • 2017-01-01
    • 2016-12-28
    • 1970-01-01
    相关资源
    最近更新 更多