Can not run REPL sml-mode in Emacs (Mac)

656 views Asked by At

System: El Capitan v10.11.15

Installed Emacs and smlnj

which smlnj gives me: /usr/local/bin/sml

adjusted my .bash_profile : export PATH="$PATH:/usr/local/bin/sml"

and .emacs to :

(setenv "PATH" (concat "/usr/local/bin/sml:" (getenv "PATH")))

(setq exec-path (cons "/usr/local/bin/sml" exec-path))

and now when I do C-c C-s on sml file it gives me:

Searching for program: no such file or directory!

Any one can help me?

2

There are 2 answers

1
rprimus On

Mon Jan 2 16:44:47 GMT 2017

[Can't add a comment as just shy of 50 reputation points.]

A few details that were left out in the info provided:

  1. $PATH and exec-path need directories - not the file name to the sml binary. export PATH=$PATH:/usr/local/bin It would be better to put this in .bashrc (so it is available in a newly started shell)

  2. What version of emacs

  3. What version of smlnj
  4. What related sml packages do you have installed?
  5. Is an sml related mode active when the file is opened?
  6. Does the file have the correct extension that will activate an sml mode?
  7. What is C-c C-s bound to? [I've got tuareg installed and C-c C-s is bound to run utop]

A point of note - which smlnj should produce smlnj not found. (which sml will produce /usr/local/bin/sml)

0
Tim X On

Assuming you have used homebrew or similar to install emacs and sml.

A few things to watch out for

  • Your PATH environment should be a list of directory paths, not file paths i.e.

    export PATH=$PATH:/usr/local/bin

in your .bash_profile. Note that PATH settings should go in bash_profile rather than .bashrc. The difference is that bash_profile is sourced once on login while bashrc is sourced for every interactive shell, so it is good to keep bashrc as small as possible. However, with the path setting, there is another 'gotcha' if you plan to run emacs from launchpad because launchpad does not source your bash_profile OR bashrc file.

There are various ways to get environment settings into luanchpad configs, but the easiest solution for the PATH setting is to just add /usr/local/bin tot the global environment. Easiest way to do this is to just add /usr/local/bin on a line in the /etc/paths file (you will need to use sudo to edit that file).

  • There is a vary useful emacs ELPA package called exec-path-from-shell which makes setting up the exec path stuff vary easy. Recommend installing that package. There are some other useful OSX specific packages in the melpa archives which you may also find useful for improving Emacs and OSX integration.