2
votes

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 setup an OCaml environment on a virtual machine running ubuntu, but I run into the same problem.

Sorry for the low level question.

3

3 Answers

3
votes

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!

2
votes

just create it. Also, you may find interesting the user-setup package, installable with opam install user-setup.

1
votes

The toplevel/utop will search for .ocamlinit in the current directory and if not found there, in the home directory. It sounds like you want the home directory.

If the file you want doesn't exist already, just create it with a text editor. It's a good idea to start with something like

print_string "test\n";;

so you can see whether the init file is taking effect. If you start utop and don't see test, it didn't work.