簡體   English   中英

如何在Mac Emacs中運行Scheme? - “過程方案異常退出,代碼為1/126”

[英]How To Run Scheme in Mac Emacs? - “process scheme exited abnormally with code 1 / 126”

具有相似標題(鏈接)的問題不包括我遇到的具體錯誤,因此新問題。

語境:

我正在嘗試建立一個在emacs中使用scheme的環境,這樣我就可以完成SICP書了。 我知道可以很好地整合這兩者,以便它們能很好地協同工作。 我知道有很多方法可以做到這一點,即使有額外的功能(我已經看到名字嘎嘎/球拍...)但這些似乎是更高級的選項。 由於我在emacs中設置這個基本的“運行方案”時遇到了麻煩,所以我沒有廣泛地研究這些選項。


我在哪里/我嘗試過的:


  1. 我下載了MIT:用於OS X的GNU方案9.2 (x86-64)。 這按預期工作,我可以從終端運行解釋器:

     $ scheme 

    或者通過執行文件“/ Applications / MIT:GNU Scheme.app/Contents/Resources/mit-scheme”(在新的終端窗口中打開解釋器)。

    此時,Mx run-scheme返回一條消息,指出不存在此類文件或目錄。

    我讀了 兩個問題作為參考,然后:


  2. 我創建了一個指向binary / exec文件的符號鏈接“/ Applications / MIT:GNU Scheme.app/Contents/Resources/mit-scheme”(從finder /終端執行時效果很好),然后將此文件放在“/ usr / bin“with name”scheme“。

    此時Mx run-scheme返回:

     /usr/local/Cellar/emacs/24.5/Emacs.app/Contents/MacOS/Emacs:/usr/bin/scheme: Exec format error Process scheme exited abnormally with code 126 

  3. 符號鏈接文件顯得很不合時宜bin文件夾所以不知道還有什么嘗試我刪除了符號鏈接,而是創建了MIT-方案EXEC文件的實際拷貝並放置 “的/ usr / bin”中。

    Mx run-scheme現在返回:

     /usr/bin/scheme: can't find a readable default for option --band. searched for file all.com in these directories: /Applications/mit-scheme.app/Contents/Resources Inconsistency detected. Process scheme exited abnormally with code 1 

尋求幫助以理解這些錯誤消息讓我找到了關於在Windows操作系統上設置方案的問題的線索,這令人困惑,我覺得我現在已經超出了我的深度 - 希望有人知道我哪里出錯了。

結束

這看起來很奇怪,因為我知道'Mx run-scheme'命令試圖訪問位置“/ usr / bin / scheme”,我確保這樣的位置存在,並且該位置的方案exec文件有效正確 - 我不明白emacs的其他要求是什么工作。

run-scheme命令實際上是做什么的? 它有什么其他要求按預期運作?

MIT Scheme在從可執行文件路徑派生的位置查找其庫(包括其“band”)。 如果庫位於非標准位置,則mit-scheme可執行文件將找不到它們。

例如,在我的設置中,MIT方案位於: /usr/local/scheme/bin/mit-scheme ,頻帶和其他內容位於/usr/local/scheme/lib/mit-scheme/

對於Emacs我已經定義:

(defun mit-scheme () 
  (interactive)
  (run-scheme "/usr/local/scheme/bin/mit-scheme -library /usr/local/scheme/lib/mit-scheme")) 

這確保了mit-scheme可以在Emacs中執行Mx mit-scheme時找到它的庫。 如果我想要MIT Scheme作為默認值,我會使用:

(setq scheme-program-name "/usr/local/scheme/bin/mit-scheme -library /usr/local/scheme/lib/mit-scheme")

您需要根據您的安裝設置值。 您也可以選擇將MIT Scheme相關的環境變量設置為指向庫位置。 相關的是MITSCHEME_LIBRARY_PATH。

$ mit-scheme --help
Usage: mit-scheme --OPTION ARG ... --OPTION ARG ...

This machine accepts the following command-line options.  The options
may appear in any order, but they must all appear before any options
for the band.

--library PATH
  Sets the library search path to PATH.  This is a colon-separated
  list of directories that is searched to find various library files,
  such as bands.  If this option is not given, the value of the
  environment variable MITSCHEME_LIBRARY_PATH is used; if that isn't
  defined, "/usr/local/lib/mit-scheme" is used.

--band FILENAME
  Specifies the initial band to be loaded.  Searches for FILENAME in
  the working directory and the library directories, returning the
  full pathname of the first readable file of that name.  If this
  option isn't given, the filename is the value of the environment
  variable MITSCHEME_BAND, or if that isn't defined, "runtime.com"; in
  these cases the library directories are searched, but not the
  working directory.

...

我也在嘗試使用SICP的材料。 花了幾個小時試圖讓事情發揮作用。

在遵循不要恐慌之后,我意識到我的路徑錯了 在Mojave上(macOS 10.14)。

我從運行安裝步驟的源安裝了mit-scheme 10.1.5, 從這里和自述文件中。 我的路徑不同,導致--band命令失敗。

如果您遇到問題,請仔細檢查您的所有路徑是否符合預期。

我使用make install和默認路徑安裝到/usr/local/bin/usr/local/lib

Mac附帶了emacs 22.1.1,這是舊的,但它可以與教授的額外腳本一起使用來自定義emacs。

注意:如果您退出emacs 22.1.1,它不會警告您停止方案 ,這將導致100%的CPU使用過程,如果沒有活動監視器,您將無法停止。 較新版本的emacs將在退出之前提示您退出方案進程(可能還有舊版本的設置)。

我使用Homebrew安裝了emacs 26.1,並且在修復這些問題后能夠運行所有內容:

新版本的emacs(24+?)有一個錯誤,帶有ad-advised-definition-p -advice ad-advised-definition-p ,通過在第334行的“multi-term.el”中注釋掉該函數來修復它:

; (defcustom multi-term-dedicated-skip-other-window-p nil
;   "Default, can have `other-window' select window in cyclic ordering of windows.
; In cases you don't want to select `multi-term' dedicated window, use `other-window'
; and make `multi-term' dedicated window as a viewable sidebar.
;
; So please turn on this option if you want to skip `multi-term' dedicated window with `other-window'.
;
; Default is nil."
;   :type 'boolean
;   :set (lambda (symbol value)
;          (set symbol value)
;          (when (ad-advised-definition-p 'other-window)
;            (multi-term-dedicated-handle-other-window-advice value)))
;   :group 'multi-term)

路徑設置

我有一個警告:

Warning (initialization): Your ‘load-path’ seems to contain
your ‘.emacs.d’ directory: ~/.emacs.d
This is likely to cause problems...
Consider using a subdirectory instead, e.g.: /Users/paulsolt/.emacs.d/lisp

通過將~/.emacs文件的頂行指向:

;; (setq load-path (append (list "~/.emacs.d") load-path))
(setq load-path (append (list "/Users/paulsolt/.emacs.d/config") load-path))

配置文件夾已經有了所有腳本,我認為我在讓Emacs看到時遇到了問題。

我從源代碼安裝了scheme而沒有修改安裝路徑,所以我更改了這一行:

;; This is the place where you have installed scheme. Be sure to set
;; this to an appropriate value!!!
;;(setq scheme-root "/mit/6.945")
(setq scheme-root "/usr/local")

接下來修復導致--band失敗的問題我修改了這一行。

(setq scheme-program-name
      (concat
       scheme-root "/bin/mit-scheme "
       "--library " scheme-root "/lib/mit-scheme-c "
       ;;"--band " scheme-root "/lib/mit-scheme-c/all.com "
       "--band " scheme-root "/lib/mit-scheme-x86-64/all.com "     
       "-heap 10000"))

我的方案庫安裝在mit-scheme-x86-64文件夾中。

最后,似乎還有一些其他命令我要注釋掉,因為它們似乎不存在......

;;(tool-bar-mode -1)
;;(scroll-bar-mode -1)

完成所有設置后,我現在可以在emacs中創建一個方案腳本,我可以使用元鍵運行腳本(iTerm將我的Alt鍵設置為Esc +):

M-x run-scheme

提示:作為 emacs的,我可以通過Emacs教程工作(章T),如果你打算在基於文本的方法是至關重要的。 在大學里,我在終端之外使用了emacs,但是這次我將它放到終端里面以了解更多熱鍵。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM