I succeeded in installing smlnj on my MAC OS 10.14 Mojave. It works just fine in terminal. Then, I got into trouble with sml package installation in emacs. When I type something in a .sml file, color and indents are all correct. However, when I do C-c C-s and hit enter, it shows, "sml: unable to determine architecture/operating system," and thus I am not able to do anything in this buffer, such as type 1+1; or anything else. Is there any hint on how to get around this issue? I've been stuck here the whole day. Thanks in advance!
1 Answers
This appears to be a problem in SML/NJ's run-time system:
I've only got the source code for 110.77, and I don't know what version of SML/NJ you are running, but here's how I go through the debug process and what you can do afterwards:
$ ack "unable to determine arch" smlnj
config/_heap2exec
24: die "unable to determine architecture/operating system"
config/_link-sml
47: echo "$CMD: unable to determine architecture/operating system"
config/_run-sml
62: echo "$CMD: unable to determine architecture/operating system"
Perhaps Emacs does not export the proper environment variables for SML/NJ's binary to properly detect the operating system. Digging into config/_run-sml
, this looks like the code that causes the error message:
ARCH_N_OPSYS=`"$BIN_DIR/.arch-n-opsys"`
if [ "$?" != "0" ]; then
echo "$CMD: unable to determine architecture/operating system"
exit 1
fi
eval $ARCH_N_OPSYS
Inside config/_arch-n-opsys
there's a switch statement for MacOS:
Darwin)
case `uname -p` in
powerpc)
ARCH=ppc
case `uname -r` in
9*) OPSYS=darwin; HEAP_OPSYS=darwin ;; # MacOS X 10.5 Leopard
*) exit 1;;
esac;;
i386) ARCH=x86;
case `uname -r` in
9*) OPSYS=darwin; HEAP_OPSYS=darwin ;; # MacOS X 10.5 Leopard
10*) OPSYS=darwin; HEAP_OPSYS=darwin ;; # MacOS X 10.6 Snow Leopard
11*) OPSYS=darwin; HEAP_OPSYS=darwin ;; # MacOS X 10.7 Lion
12*) OPSYS=darwin; HEAP_OPSYS=darwin ;; # MacOS X 10.8 Mountain Lion
13*) OPSYS=darwin; HEAP_OPSYS=darwin ;; # MacOS X 10.9 Mavericks
14*) OPSYS=darwin; HEAP_OPSYS=darwin ;; # MacOS X 10.10 Yosemite
*) exit 1;;
esac;;
The shell script .arch-n-opsys
is one that determines the operating system you're using. So it seems that SML/NJ 110.77's run-time system does not detect MacOS beyond 10.10. Why this is not a problem outside of Emacs I'm not sure.
You could try and run the program from within Emacs via M-x shell
RET and type:
cd /usr/lib/smlnj/bin
ls -a
./.arch-n-opsys
I suspect that you can fix this problem locally if you replace this .arch-n-opsys
binary with a tiny shell script that hardcodes your preferred options, which are probably:
#!/bin/sh
echo "ARCH=darwin; OPSYS=darwin; HEAP_SUFFIX=darwin-darwin"
If that doesn't work, maybe some of the other options that the original .arch-n-opsys
shell script lists will work.
Only in case you're interested in fixing the problem for others:
Find out if the latest version, 110.85, supports MacOS > 10.10.
If not, write to the email at the bottom of smlnj.org and link to this StackOverflow post and say what
uname -r
does on your system, or supply a diff that works for your system in particular.

- 15,635
- 1
- 41
- 66