Search code examples
ocaml

Can't find .ocamlinit file


I'm trying to get an OCaml environment set up for the Real World OCaml book.

I need OCaml, OPAM, Utop and the Core library. I've been able to install OCaml, OPAM and Utop but I have problems setting up the Core library.

I'm in OS X and I've already installed Core by:

opam install core
opam install async
opam install core_extended

Now I should add some lines to my .ocamlinit file. The problem is, I'm kind of a noob and I don't know where this file is located exactly or how I can access it. The file should be in my home directory but I can't seem to find it and I'm not sure I know what this means exactly.

I've also tried to set up an OCaml environment on a virtual machine running Ubuntu, but I run into the same problem.


Solution

  • The file is located in your home directory. It is your current directory when you open your terminal. You don't see this file because it starts with a ".", this it's hidden and finder can't see it. In your terminal you can see all hidden files by

    ls -a
    

    I recommend you use emacs to edit this file, by

    emacs .ocamlinit
    

    This will open the .ocamlinit file with the emacs editor.

    Then just paste your text into it and do ctrl+x ctrl+s to save and ctrl+x ctrl+c to quit and you're done!