4
votes

When I try to use the function List.nth, the sml shell returns this error message:

- List.nth([1,2,3],0);
[autoloading]

unexpected exception (bug?) in SML/NJ: Io [Io: openIn failed on "/Users/jhr/Work/smlnj/osx-dist/smlnj.dst/sml.boot.x86-unix/smlnj/basis/.cm/x86-unix/basis.cm", No such file or directory]
raised at: Basis/Implementation/IO/bin-io-fn.sml:617.25-617.71
         ../cm/util/safeio.sml:30.11
         ../compiler/TopLevel/interact/evalloop.sml:42.54

It returns same error message if I use nth without List. as well. So I can guess that there is something problem with 'autoloading' the library.

But there are some strange things more. If I use another basis library function length, it works fine. Like this:

- length ([1,2,3]);
val it = 3 : int

But what if I use List.length? It goes to error. Like this:

- List.length([1,2,3]);
[autoloading]

unexpected exception (bug?) in SML/NJ: Io [Io: openIn failed on "/Users/jhr/Work/smlnj/osx-dist/smlnj.dst/sml.boot.x86-unix/smlnj/basis/.cm/x86-unix/basis.cm", No such file or directory]
 raised at: Basis/Implementation/IO/bin-io-fn.sml:617.25-617.71
         ../cm/util/safeio.sml:30.11
         ../compiler/TopLevel/interact/evalloop.sml:42.54

So it seems there is definitely something wrong with 'autoloading' stuff, but I can't figure out how to fix it. Please help me finding the problem and fixing it!

Note:

  1. I use Max OS X 10.13.3, and SML/NJ compiler of v110.81
  2. 'jhr' in the path is the previous 'user name'. I changed to 'cadenzah'. That is why that path does not exist. There is 'cadenzah' directory in 'Users' directory.

ps. Maybe there is something problem with directory structure of complier itself between previous version and this(v110.81)?

3

3 Answers

2
votes

How did you install SML/NJ on your Mac?

It seems that the compiler resides in a user-owned directory; I would recommend that you try and install SML/NJ via Homebrew as this blog post instructs:

$ ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go)
$ brew update
$ brew install smlnj

Since you're not asking how to install SML/NJ, this isn't a duplicate of the following questions:

But perhaps you should be asking that question instead and not this one. :)

Otherwise, try and set the current username to 'Cadenzah' instead of 'cadenzah' so it matches the capitalisation of your user directory. Unix filesystems tend to be case sensitive. Even though MacOS is not, by default, this may cause some conflicts in software that don't respect local filesystem laws.

1
votes

If you are having this issue and can't resolve it by using homebrew to install, try setting the environment variable SMLHOME_DIR to the installation directory. This may resolve some "File not found" errors.

Example:

% pwd
/usr/local/smlnj
% ls
MLRISC/  bin/   cml/     doc/  ml-burg/  ml-lpt/   nlffi/  smlnj-lib/            license.html
base/    ckit/  config/  lib/  ml-lex/   ml-yacc/  null    trace-debug-profile/
% export SMLNJ_HOME=/usr/local/smlnj/

You can then add that to your .zshrc, etc.

0
votes

I solved the same issue by exporting SMLNJ_HOME mentioned in SML's MacOS installation documentation.

Execute:

echo 'export SMLNJ_HOME="/usr/local/smlnj"' >> $HOME/.bash_profile

Then, source it into your current command line environment:

source $HOME/.bash_profile

SML is then capable of loading extra functions from the core library:

Standard ML of New Jersey v110.79 [built: Sun Oct  4 14:45:06 2015]
- List.nth;
[autoloading]
[library $SMLNJ-BASIS/basis.cm is stable]
[library $SMLNJ-BASIS/(basis.cm):basis-common.cm is stable]
[autoloading done]
val it = fn : 'a list * int -> 'a