Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ocamlfind cannot see installed package

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.

like image 436
Stephen Dedalus Avatar asked Jan 03 '14 22:01

Stephen Dedalus


2 Answers

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.

like image 77
TheNiceGuy Avatar answered Jan 11 '23 01:01

TheNiceGuy


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).

like image 34
Stephen Dedalus Avatar answered Jan 11 '23 00:01

Stephen Dedalus