今回はSBCLを使う。OSはmacOS、SBCLのインストールには手軽なのでHomebrewを使う。
sbclのインストールからSLIMEの起動まで
brew install sbcl
簡単なプログラムを書いて実行してみる。
sbcl --script main.lispOk
良さそうだ。
SLIMEはpackage.elでも入れられるが、今回はGitHubからcloneする。
git clone [email protected]:slime/slime.gitload-pathを通し、諸々の設定を行う1。
(add-to-list 'load-path "/opt/ng/slime")
(setq inferior-lisp-program "/usr/local/bin/sbcl")
(require 'slime)
(slime-setup '(slime-repl slime-fancy slime-banner))設定は通常初期化時に読み込むようにするが、今回はすぐ使いたいので評価しておく。
先程のmain.lispを開き、SLIMEを起動する。
M-x slime
SLIMEの起動に失敗する場合、/etc/hostsにおかしな行がないか確認する
M-x slime を実行すると通常はSLIMEが起動するが、環境によっては起動しない事がある。僕の環境は起動せず、少しハマった。その時は、以下のエラーが出力されていた。
; This is SBCL 2.3.9, an implementation of ANSI Common Lisp.
; More information about SBCL is available at <http://www.sbcl.org/>.
;
; SBCL is free software, provided as is, with absolutely no warranty.
; It is mostly in the public domain; some portions are provided under
; BSD-style licenses. See the CREDITS and COPYING files in the
; distribution for more information.
; * ; loading #P"/opt/ng/slime/swank-loader.lisp"
; WARNING:
; redefining EMACS-INSPECT (#<SB-PCL:SYSTEM-CLASS COMMON-LISP:T>) in DEFMETHOD
;
; debugger invoked on a SB-BSD-SOCKETS:SOCKET-ERROR in thread
; #<THREAD "main thread" RUNNING {10010A8003}>:
; Socket error in "bind": 49 (Can't assign requested address)
;
; Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
;
; restarts (invokable by number or by possibly-abbreviated name):
; 0: [USE-VALUE] Try a port other than 0
; 1: [ABORT ] Exit debugger, returning to top level.
;
; (SB-BSD-SOCKETS:SOCKET-ERROR "bind" 49)
; ; File has been modified since compilation:
; ; SYS:CONTRIB;SB-BSD-SOCKETS;SOCKETS.LISP.NEWEST
; ; Using form offset instead of character position.
;
; source: (ERROR (CONDITION-FOR-ERRNO ERRNO) :ERRNO ERRNO :SYSCALL WHERE)
; 0]
;
似たような報告が幾つかある234。僕の環境は正にこれを踏んでいた。 /etc/hosts に妙な行がDockerによって追加されいた。
172.18.0.5 localhost
そこで、これをコメントアウトすると起動するようになった。