1

I have installed scmutils (for the book SICM) from the tar ball under /usr/local.

I then put this in my .emacs:

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

which is mostly instruction from http://redsymbol.net/articles/using-gnu-emacs-with-scmutils/.

But I get an error:

/usr/local/scmutils/mit-scheme/bin/scheme: 1: /usr/local/scmutils/mit-scheme/bin/scheme: 
Syntax error: "(" unexpected

Process scheme exited abnormally with code 2

I also tried running /usr/local/bin/mechanics, which is a shell script that run eventually run:

$ /usr/local/scmutils/mit-scheme/bin$ /usr/local/scmutils/mit-scheme/bin/scheme --library /usr/local/scmutils/mit-scheme/lib --heap 12000 --band edwin-mechanics.com --edit

$ bash: /usr/local/scmutils/mit-scheme/bin/scheme: cannot execute binary file

I think there's some incompatibility. Here is the "file mit-scheme-x86-64":

mit-scheme-x86-64: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, BuildID[sha1]=0x88f52caf274bb8298a0f6b84fc34beb9d2094bc6, not stripped

and

$ uname -r 

3.11.0-26-generic

Anyone can guide me how to debug this now? I am running Ubuntu in VMWare Fusion (Mac OS X).

Flux
  • 9,805
  • 5
  • 46
  • 92
kawingkelvin
  • 3,649
  • 2
  • 30
  • 50
  • 1
    is this for the SICM book? – Will Ness Sep 21 '14 at 09:13
  • yes, I am re-reading this book after many yrs. – kawingkelvin Sep 21 '14 at 18:17
  • I've gotten that code to work perfectly on Arch Linux, including getting `show-expression` in the emacs shell version of scmutils to pop up an xdvi window to show latex expressions. It should work on ubuntu as well; there was nothing special I needed to do beyond what you have there. I would double check the `defun` there (also post the code here in block form using `C-k`. The mechanics script opens up an xterm window with Edwin, which is significantly pared down version of emacs, lacking many features. I would greatly recommend using emacs instead of Edwin here. – xdavidliu Mar 18 '18 at 03:19
  • update: graphical xdvi show-expression from within emacs works on macos as well. You just need to manually setenv the PATH variable inside emacs to include the directory that xdvi is located in. See my other comment below. – xdavidliu Jul 11 '18 at 06:26

2 Answers2

1

The direct answer to the body of the question is probably that VMWare can't recognize the binary.

For the more general problem of how to run scmutils from Emacs, here are the steps for Debian and macOS:

Debian:

First make sure you have MIT-scheme. If not, do sudo apt install mit-scheme. Then, download the tarball from the official scmutils page. Extract it and sudo ./install.sh. Also, sudo cp mechanics.sh /usr/local/bin/mechanics, and now you can run scmutils from bash by doing either mechanics (to run in terminal) or mechanics -edit (to pop up an Edwin). You also need to sudo apt install texlive if you haven't already. Then, confirm that show-expression works by doing mechanics -edit to open Edwin (if the font is too small, see my answer to another question), then (show-expression '(sqrt (+ x y))) and then M-z and it will pop up a window with the Latex.

Great, show-expression works natively on Edwin! To get it working on emacs is easy. First, open up emacs, evaluate (require 'xscheme) (This seems to change the meaning of the run-scheme command), then do (run-scheme "/usr/local/bin/mechanics"), and you will see a scmutils REPL in your emac. At this point, evaling (up 1 2 3) should work, though note that unlike Edwin, you need C-x C-e to eval' M-z won't work here. Finally, eval (show-expression '(sqrt (+ x y))), and it will work.

Proof screenshot I just took right after writing this

macOS:

These instructions taken from the comments in this thread; I wrote them a year ago and no longer use macOS, so cannot confirm them now, but they should work.

Install Xquartz and "emacs for macOS" and also BasicTex. Then using brew, install mit-scheme and gv. Finally, install scmutils from the tarball like in the Debian part above. Confirm that show-expression works in Edwin, then in emacs, repeat the steps above from the Debian section, and also make sure to use setenv to add /Library/TeX/texbin to PATH. Then, show-expression should work from emacs.

(again, I don't have a macbook to confirm now, but I got it working about a year ago when I wrote the other comments in this page, using similar, if not identical instructions to the above).

xdavidliu
  • 2,411
  • 14
  • 33
0

I think the problem may be VMWare Fusion. I ran this successfully on Mac OS X and native ubuntu.

kawingkelvin
  • 3,649
  • 2
  • 30
  • 50
  • I ran this successfully on Mac OS X and also Arch linux. However on Mac OS X, I couldn't do `(show-expression '(+ x y))`, which is supposed to pop up a xdvi window. This is probably because of a bug in the gui version of emacs for which the environment variables needed for displaying xterm windows are not set. For Arch linux though, everything works perfectly, even in GUI version of emacs. – xdavidliu Mar 18 '18 at 03:17
  • update: I managed to get graphical xdvi show-expression working on Mac OS as well. What I did was install xquartz, then basictex, and also brew install gv. Then, in emacs, must use setenv to add "/Library/TeX/texbin" to PATH. Then, emacs mechanics knows to use xdvi when doing show-expression – xdavidliu Jul 11 '18 at 06:25