# Weird Array library unbound error

**URL:** <https://discuss.ocaml.org/t/weird-array-library-unbound-error/1089>\
**Category:** Learning\
**Created:** [November 8, 2017, 7:43pm UTC](https://discuss.ocaml.org/t/weird-array-library-unbound-error/1089 "2017-11-08T19:43:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![s19961](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@s19961](https://discuss.ocaml.org/u/s19961)\
**Post date:** [November 8, 2017, 7:43pm UTC](https://discuss.ocaml.org/t/weird-array-library-unbound-error/1089/1 "2017-11-08T19:43:30Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![dra27](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dra27/32/5294_2.png) [@dra27](https://discuss.ocaml.org/u/dra27)\
**Post date:** [November 8, 2017, 10:31pm UTC](https://discuss.ocaml.org/t/weird-array-library-unbound-error/1089/2 "2017-11-08T22:31:20Z")

</div>

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`?

---

<div class="post-metadata">

**Author:** ![s19961](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@s19961](https://discuss.ocaml.org/u/s19961)\
**Post date:** [November 8, 2017, 11:04pm UTC](https://discuss.ocaml.org/t/weird-array-library-unbound-error/1089/3 "2017-11-08T23:04:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dra27](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dra27/32/5294_2.png) [@dra27](https://discuss.ocaml.org/u/dra27)\
**Post date:** [November 8, 2017, 11:25pm UTC](https://discuss.ocaml.org/t/weird-array-library-unbound-error/1089/4 "2017-11-08T23:25:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![s19961](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@s19961](https://discuss.ocaml.org/u/s19961)\
**Post date:** [November 8, 2017, 11:53pm UTC](https://discuss.ocaml.org/t/weird-array-library-unbound-error/1089/5 "2017-11-08T23:53:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![s19961](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@s19961](https://discuss.ocaml.org/u/s19961)\
**Post date:** [November 9, 2017, 12:30am UTC](https://discuss.ocaml.org/t/weird-array-library-unbound-error/1089/6 "2017-11-09T00:30:59Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![dra27](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dra27/32/5294_2.png) [@dra27](https://discuss.ocaml.org/u/dra27)\
**Post date:** [November 9, 2017, 11:31am UTC](https://discuss.ocaml.org/t/weird-array-library-unbound-error/1089/7 "2017-11-09T11:31:47Z")

</div>

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.
