Weird Array library unbound error

I’m a beginner using Ocaml 4.01 and for some reason, I can’t access any functions in the Array module! For ex, when I type Array.set;; into my terminal or toplevel, I get “Unbound value Array.set”. Weirdly, the only Array function that works, is Array.make. Does anyone have any idea how I can fix this? Thanks!

Out of curiosity, why are you using OCaml 4.01 (it’s very old)?

What files do you have in the directory you’re invoking ocaml from? What happens if you try running ocaml -noinit?

It’s just the version that came installed with Ubuntu 16.04 and I’m not sure how to get a more recent version. When I do ocaml -noinit I get a menu of options that seem to allow me to disable certain functions. I do seem to have the Array and bigarray files. I’m wondering if there’s an easy way/effective to completely remove all ocaml files(I have a lot…from attempting to delete and reinstall…poorly) and re-install?

Xenial ships 4.02.3 - when did you last install updates?

I forgot that the -noinit switch wasn’t added until 4.02.0, so sorry about that. Does the directory you’re running ocaml from contain a .ocamlinit file or does ~/.ocamlinit exist?

An easy way to upgrade OCaml is to use opam - sudo apt install opam followed by opam init followed by opam switch 4.05.0.

I updated opam, switched to 4.05.0, and after using opam config env, I see all of the path variables for the 4.05.0 version. However afterwards when I check the ocaml version, it still says 4.01.1.
Also it is running with a .ocamlinit file.

iNevermind - now that i’ve switched to 4.05.0, the array library works! I’m curious as to why it wasn’t in the old version. Thank you for your help!

What do you mean by “afterwards”? You have to run eval $(opam config env) in every shell (or put it in your .bashrc, etc.).

What was in your .ocamlinit - my best guess was that you were opening something which was overriding the Array module in some way. Although if that were correct, it should have been affecting 4.05.0 too.