ocamlfind cannot see installed package

11.3k views Asked by At

I wanted to compile my project using command:

ocamlfind ocamlopt -package ocamlnet -package batteries -package unix -linkpkg oauth.ml

but I'm getting following error:

ocamlfind: Package `ocamlnet' not found
make: *** [oauth.cmi] Error 2

After some research on this problem I have read that there may be problem with packages installed via opam and packages installed before opam installation (in this case with ocamlfind) so I tried to check that and get stuck because ocamlfind is installed via opam. Does anybody know what may I try to do to solve that problem?

$ which ocamlfind
/home/user/.opam/4.00.1/bin/ocamlfind

$ opam list 
Installed packages for 4.00.1:
[...]
ocamlfind             1.4.0  A library manager for OCaml
[...]

Thanks in advance.

2

There are 2 answers

7
TheNiceGuy On

Do a:

eval $(opam config env)

That should fix the problem.

# Edit 1:

If it still does not work remove the dir

/home/user/.opam/4.00.1

and try it again.

0
Stephen Dedalus On

I'm making answer because of limit in comments and partial results I've made. Here is the result of 'grep -r 'ocamlnet' *' at '~/.opam' directory: http://pastebin.com/8cJqMXDY by looking at lines 1-90 we may conclude that there is actually no ocamlnet library at all (or I'm looking for it in wrong place - but as I wrote in comment everything were installed using opam - I'd be glad to hear some opinions on this subject). These suspicions may be partially confirmed in two ways:

  1. in fact in lines 1-90 we've all binaries of ocamlnet components (http://projects.camlcity.org/projects/dl/ocamlnet-3.7.3/doc/html-main/index.html)
  2. lines 90-* doesn't seem like something other than some files needed to manage this package using opam. E.g.

    ~/.opam/repo/default/packages/ocamlnet$ tree -r .
    .
    ├── ocamlnet.3.7.3
    │   ├── url
    │   ├── opam
    │   ├── files
    │   │   └── ocamlnet.install
    │   └── descr
    ├── ocamlnet.3.6.5
    │   ├── url
    │   ├── opam
    │   ├── files
    │   │   ├── ocamlnet.install
    │   │   ├── netpop.patch
    │   │   ├── nethttpd_types.patch
    │   │   └── cloexec.patch
    │   └── descr
    ├── ocamlnet.3.6.3
    │   ├── url
    │   ├── opam
    │   ├── files
    │   │   └── ocamlnet.install
    │   └── descr
    ├── ocamlnet.3.6.0
    │   ├── url
    │   ├── opam
    │   ├── files
    │   │   ├── ocamlnet-ocaml4.diff
    │   │   └── ocamlnet.install
    │   └── descr
    ├── ocamlnet.3.5.1
    │   ├── url
    │   ├── opam
    │   ├── files
    │   │   └── ocamlnet.install
    │   └── descr
    └── ocamlnet.3.2.1
        ├── url
        ├── opam
        ├── files
        │   └── ocamlnet.install
        └── descr
    

I do not have a sufficiently large knowledge to go into it deeper but it looks for me like that ocamlnet become just a shortcut for a few another packages used by opam. Especially that after changing

-package ocamlnet

to exact module which I'm using

-package netstring

everything has compiled fine. I'm still open to any other solutions or explenations for the curious case of ocamlnet package (and Michael's hints) B).