Howto to configure spacemacs with OCaml on windows

Hello,

when I can program, I’m mainly using OCaml on Linux with Spacemacs as an editor (and more).

But I often have to switch to a windows virtual machine in order to compile before delivering my work to co-workers.

On this platform, I installed OCaml with the excellent OCaml for Windows.

But I was not able to install and configure correctly Spacemacs with everything working. By instance, I can’t have Merlin work as expected. This is bad, because I would sometime need to do serious job without switching back to Linux.

Does anybody have some simple instruction to help me (and certainly others) towards this? Which version of emacs are you using? How to you configure it? Does your configuration adapt automatically when switching in OPAM?

Thanks for any help

1 Like

Not sure about spacemacs, but the following steps should work with stock emacs:

  • Download and extract latest windows version from https://ftp.gnu.org/gnu/emacs/windows/
  • Start “runemacs.exe” through ocaml-env-win (https://fdopen.github.io/opam-repository-mingw/ocaml-env/). You can create a shortcut from within cygwin, e.g. on your desktop:
    mkshortcut -a /cygdrive/c/path-to-emacs/bin/runemacs.exe -D /usr/local/bin/ocaml-env-win -n Emacs -w "$HOME" -i /cygdrive/c/path-to-emacs/bin/runemacs.exe
  • enable melpa repository and install dependencies (company-mode,…)
  • opam install merlin and add the suggested code to your ~/.emacs file
1 Like

I’ll have to pull out my old laptop to check for any tweaks, but I believe I used spacemacs on Windows through this setup.

Thanks for your answer.

I must have a problem with my installation, but can’t find out what it is?

$ opam switch
#   switch                          compiler                        description
->  ocaml-variants.4.07.1+mingw64c  ocaml-variants.4.07.1+mingw64c  ocaml-variants.4.07.1+mingw64c

$ ocaml -version
The OCaml toplevel, version 4.07.1

$ echo $HOME
/home/MatthieuDubuget

$ ocaml-env-win.exe -- ~/emacs-26.1/bin/runemacs.exe
fatal error:$HOME not found

First of all, I’m not sure where this fatal error:$HOME not found message comes from?

Any idea?

Best regards