6

I've installed OPAM and run the initialization and updated my .bashrc code too. I then installed the ocamlfind package, which went successfully. But when I try

#use "topfind";;

I get the following

Cannot find file topfind

I'm running ocaml 4.00.1 built from source on Opensuse 12.2.

Jatajuuf
  • 301
  • 3
  • 11

3 Answers3

8

First, you need to export the right environment variables by doing:

eval `opam config env`

To be more effective, you should put that line in your ~/.profile (or ~/.bashrc).

Then, if you are using the system compiler, you can add these lines to your ~/.ocamlinit:

let () =
  try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")
  with Not_found -> ()

We are working on improving this process before releasing 1.0.

Thomas
  • 5,047
  • 19
  • 30
  • This worked too. Thanks for OPAM, I never could get GODI running before and installing libraries used to be a pain, now it's a cinch! – Jatajuuf Feb 07 '13 at 13:53
4

If $OCAML_TOPLEVEL_PATH is not defined, you have to defined it:

export OCAML_TOPLEVEL_PATH=/home/%user%/.opam/%version%/lib/toplevel

Don't forget to change %user% and your compiler %version%

Check this issue on the opam bugtracker.

Çağdaş Bozman
  • 2,537
  • 16
  • 21
  • Hi, there is no version directory in the ".opam" directory. There are only `aliases` `archives` `compilers` `config` `descr` and others like that. – Jatajuuf Feb 07 '13 at 13:30
  • I added a small modification, the path was `/home/%user%/.opam/system/lib/toplevel` and it worked. Thanks. – Jatajuuf Feb 07 '13 at 13:42
1

What if you start toplevel as

rlwrap ocaml -I "$OCAML_TOPLEVEL_PATH"

You can also try alternative toplevel: utop (it exists in OPAM)

Stas
  • 11,571
  • 9
  • 40
  • 58
  • Hi, I don't have rlwrap installed, and i've setup Emacs with the default ocaml interpreter, so I don't want to keep switching to "utop" in tuareg. Thanks anyway. – Jatajuuf Feb 07 '13 at 13:44
  • `rlwrap` is not needed. `ocaml -I "$OCAML_TOPLEVEL_PATH"` should fix the problem imho. – Stas Feb 07 '13 at 13:46
  • Once I set the `$OCAML_TOPLEVEL_PATH` variable, I could run just `ocaml` itself. – Jatajuuf Feb 07 '13 at 13:59