ocamlfind cannot see installed package
Asked Answered
S

2

9

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.

Syneresis answered 3/1, 2014 at 22:10 Comment(0)
C
23

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.

Cyclorama answered 3/1, 2014 at 22:14 Comment(7)
Unfortunatelly it's not doing anything: $ opam config env CAML_LD_LIBRARY_PATH="/home/adam/.opam/4.00.1/lib/stublibs"; export CAML_LD_LIBRARY_PATH; PERL5LIB="/home/adam/.opam/4.00.1/lib/perl5:"; export PERL5LIB; OCAML_TOPLEVEL_PATH="/home/adam/.opam/4.00.1/lib/toplevel"; export OCAML_TOPLEVEL_PATH; MANPATH=":/home/adam/.opam/4.00.1/man"; export MANPATH; PATH="..."; export PATH; $ make [...] ocamlfind: Package `ocamlnet' not found make: *** [oauth.cmi] Error 2Syneresis
You probably meant eval $(opam config env).Sombrero
@Michael It wasn't file but whole directory and actually now I have bigger problem (project is still not compiling) because now I'm getting $ opam config env [ERROR] global-config does not define the variable lib. 'opam config env' failed. and even ocaml doesn't want to run $ opam config env [ERROR] global-config does not define the variable lib. 'opam config env' failed. Will it guide me somewhere or should I better start reinstalling ocaml and rest of packages?Syneresis
Do a eval $(opam config env) as mentioned above.Cyclorama
The same error: $ eval $(opam config env) [ERROR] global-config does not define the variable lib. 'opam config env' failed.Syneresis
OK, I've just removed ./opam directories and reinstalled opam. eval $(opam config env) still doesn't work. Michael, @JonathanProtzenko Can you reveal the motivation behind removing this folder and typing 'eval $(opam config env)'? It'd help me at trying to find similar errors and maybe move on a little. Thanks in advance.Syneresis
[ERROR] global-config does not define the variable lib is typical of being in a non-existent switch. Try opam switch 4.01.0 or something like that to switch back to an existing switch.Airstrip
S
2

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

Syneresis answered 4/1, 2014 at 10:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.