By the way, the recommended way to install ocaml nowadays is to use opam. If you have opam installed, you can just do opam install base to install the base library and then everything should work.
You can install opam on OS X by doing brew install opam.
# #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
- : unit = ()
# #require "base";;
No such package: base
$ opam install base
[NOTE] Package base is already installed (current version is v0.14.1).
$ ocaml
OCaml version 4.12.0
# #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
- : unit = ()
# #require "base";;
No such package: base
$ eval $(opam env)
$ ocaml
OCaml version 4.12.0
# #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
- : unit = ()
# #require "base";;
No such package: base
Thanks a lot for your help, Nicolas, I really appreciate it. Meanwhile, I think I’d better try my luck with another language. There are many functional languages after all
Is base listed in the output? If so, then it is definitely installed in the current opam switch. If not, you need to install it with: opam install base.
Finally, it is recommended to use the enhanced OCaml REPL, utop:
$ ocamlfind printconf
Effective configuration:
Configuration file:
/usr/local/etc/findlib.conf
Search path:
/usr/local/lib/ocaml
Packages will be installed in/removed from:
/usr/local/lib/ocaml
META files will be installed in/removed from:
the corresponding package directories
The standard library is assumed to reside in:
/usr/local/lib/ocaml
The ld.conf file can be found here:
/usr/local/lib/ocaml/ld.conf
$ opam list
# Packages matching: installed
# Name # Installed # Synopsis
base v0.14.1 Full standard library replacement for OCaml
base-bigarray base
base-threads base
base-unix base
csexp 1.5.1 Parsing and printing of S-expressions in Canonical
dune 2.9.0 Fast, portable, and opinionated build system
dune-configurator 2.9.0 Helper library for gathering system configuration
ocaml 4.12.0 The OCaml compiler (virtual package)
ocaml-config 2 OCaml Switch Configuration
ocaml-system 4.12.0 The OCaml compiler (system version, from outside o
result 1.5 Compatibility Result module
sexplib0 v0.14.0 Library containing the definition of S-expressions
Hi, @gefei ! Would you mind sharing what learning material or documentation you were using to get oriented and set up with OCaml? It sounds like we’ll want to update or deprecate it (as appropriate), so we can save future users from the pain of going down tough set up paths.
Hi @shonfeder I was learning OCaml by the book “Real world ocaml” https://dev.realworldocaml.org/, and I had problem with the very first line in the first example which reads open Base;;
Thanks! I looks like RWO advises installing from opam. Is it possible you’d consulted different material initially for the installation, that advised installing from homebrew?