About "topfind"?

When I enter #use "topfind" ;; at the top level manually, it works as follows:

  #use "topfind" ;; - : unit = () Findlib has been successfully loaded. Additional directives: #require "package";; to load a package #list;; to list the available packages #camlp4o;; to load camlp4 (standard syntax) #camlp4r;; to load camlp4 (revised syntax) #predicates "p,q,...";; to set these predicates Topfind.reset();; to force that packages will be reloaded #thread;; to enable threads #use "topfind" ;; - : unit = () 

However, when I put #use "topfind";; in the ~/.ocamlinit file, it does not work:

 >cat ~/.ocamlinit #use "topfind";; #require "str";; (* #use "money.ml" ;; *) >ocaml Objective Caml version 3.12.0 # #list ;; Unknown directive `list'. 

Seems like a weird question, right?

+4
source share
2 answers

Obviously ocaml does not load this .ocamlinit. Put some print_endline in it for verification. Some ideas:

  • You can use the -init option to specify the ocamlinit file explicitly.
  • Maybe ocaml is some (wrong) alias in your shell?
  • Try strace -f -ttT -e open $(which ocaml) to see where it is looking for ocamlinit.
+5
source

YGREK

Thank you for your quick response.

You can use the -init option to specify the ocamlinit file explicitly.

%ocaml -init ~/.ocamlinit works

Maybe ocaml is some kind of (wrong) alias in your shell?

no ocaml alias

Try strace -f -ttT -e to open $ (which is ocaml) to see where it is looking for ocamlinit

 %strace -f -ttT -e open $(which ocaml) 19:12:28.484440 open("/etc/ld.so.cache", O_RDONLY) = 3 <0.000179> 19:12:28.485002 open("/lib/libm.so.6", O_RDONLY) = 3 <0.000062> 19:12:28.485384 open("/lib/libdl.so.2", O_RDONLY) = 3 <0.000062> 19:12:28.485744 open("/lib/libncursesw.so.5", O_RDONLY) = 3 <0.000061> 19:12:28.486107 open("/lib/libpthread.so.0", O_RDONLY) = 3 <0.000061> 19:12:28.486514 open("/lib/libc.so.6", O_RDONLY) = 3 <0.000060> 19:12:28.488228 open("/usr/bin/ocamlrun", O_RDONLY|O_LARGEFILE) = 3 <0.000018> 19:12:28.488425 open("/usr/bin/ocaml", O_RDONLY|O_LARGEFILE) = 3 <0.000166> 19:12:28.496499 open("/usr/lib/ocaml/ld.conf", O_RDONLY|O_LARGEFILE) = 4 <0.000028> 19:12:28.502249 open("/usr/bin/ocaml", O_RDONLY|O_LARGEFILE) = 3 <0.000021> 19:12:28.506085 open("/usr/lib/ocaml/ld.conf", O_RDONLY|O_LARGEFILE) = 4 <0.000029> 19:12:28.506880 open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3 <0.000020> Objective Caml version 3.12.1 19:12:28.507797 open("/usr/lib/ocaml/pervasives.cmi", O_RDONLY|O_LARGEFILE) = 3 <0.000019> 19:12:28.511012 open(".ocamlinit", O_RDONLY|O_LARGEFILE) = 3 <0.000018> 19:12:28.511325 open("money.ml", O_RDONLY|O_LARGEFILE) = 4 <0.000020> 19:12:28.513412 open("/usr/lib/ocaml/list.cmi", O_RDONLY|O_LARGEFILE) = 5 <0.000018> 19:12:28.514858 open("/usr/lib/ocaml/printf.cmi", O_RDONLY|O_LARGEFILE) = 5 <0.000020> 19:12:28.527847 open("/usr/lib/ocaml/sys.cmi", O_RDONLY|O_LARGEFILE) = 5 <0.000029> # 

The reason is that there is a .ocamlinit file in the current directory. therefore ocaml uses it instead of ~/.ocamlinit .

thanks!

+3
source

Source: https://habr.com/ru/post/1380312/


All Articles