Notes

Install latest SML/NJ from source on Ubuntu (20.04)

Edit on GitHub

System Administration
2 minutes

Standard ML of New Jersey isn’t used much in modern day development but i needed to install it as part of my Programming Languages course.

The simplest way to install is sudo apt -y install smlnj, but it’ll install a slightly older version.

Here are all the steps on installing SML/NJ from source. You can save this as a script and run it with sudo bash foo.sh. sudo is needed if you want to create directories and download files under /usr/local

 1#!/bin/bash
 2
 3# Make directory for SML install
 4cd /usr/local
 5mkdir smlnj
 6cd smlnj
 7
 8# Download source
 9# replace 110.99.2 with whatever the latest is at the time of install
10wget https://smlnj.org/dist/working/110.99.2/config.tgz
11
12# Extract files
13tar -xzf config.tgz
14
15# Install
16# -64 is for 64bit architecture. default install is 32bit but you can change that by passing an option
17config/install.sh -64
18
19# Update PATH
20echo '
21
22# SML/NJ
23# Standard ML of New Jersey
24# where /usr/local/sml/bin is the install location
25export PATH=$PATH:/usr/local/smlnj/bin
26' >> ~/.zshrc
  • Default SMLNJ installation is 64 bit, but for some systems you can select the architecture b/w 32bit and 64 bit by passing a flag
  • I chose /usr/local/smlnj as the install path but you can install it anywhere, just update the $PATH to include that location. /usr/local/smlnj is the default install path for macOS as well.
  • By default, it installs in the directory where you ran the config/install.sh command from
1$ sml
2Standard ML of New Jersey (64-bit) v110.99.2 [built: Mon Jul 18 12:40:59 2022]
3- 
  • Exiting the REPL is with ctrl + Z and not wth ctrl + C

Updating $PATH manually

By default, you can run sml by specifying the entire path, for example:

1cd INSTALL_LOCATION/bin
2./sml

BUt if you want to be able to just run sml from anywhere in the terminal, you need to add it to your $PATH. To do so, add the following lines to your ~/.zshrc or ~/.bashrc or ~/.bash_profile file

1# SML/NJ
2# Standard ML of New Jersey
3# where /usr/local/smlnj/bin is the install location
4export PATH=$PATH:/usr/local/smlnj/bin