# Core and Base Unbound Modules

**URL:** <https://discuss.ocaml.org/t/core-and-base-unbound-modules/16607>\
**Category:** Learning\
**Created:** [May 5, 2025, 4:54pm UTC](https://discuss.ocaml.org/t/core-and-base-unbound-modules/16607 "2025-05-05T16:54:58Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Domenico](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/domenico/32/5966_2.png) [@Domenico](https://discuss.ocaml.org/u/Domenico)\
**Post date:** [May 5, 2025, 4:54pm UTC](https://discuss.ocaml.org/t/core-and-base-unbound-modules/16607/1 "2025-05-05T16:54:58Z")

</div>

I recently got the book Real World Ocaml and I cannot even get past the installation. I followed the instructions on [ocaml.org](http://ocaml.org) as they laid out. I ran each command in sequence, I probably have reinstalled it this way 4 times by now. I can compile ocaml but I absolutely cannot get core or base to work. I am running windows 11, and my opam list shows core, base, and utop.  
I try to use # require “base”;; does not work.  
I try to create a .ocamlinit file, does not work.  
I use dune build with core and base both in the dune file  
No matter what I do, no matter how many reinstall these modules do not work. I am so lost.

---

<div class="post-metadata">

**Author:** ![shonfeder](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/shonfeder/32/424_2.png) [@shonfeder](https://discuss.ocaml.org/u/shonfeder)\
**Post date:** [May 5, 2025, 5:31pm UTC](https://discuss.ocaml.org/t/core-and-base-unbound-modules/16607/2 "2025-05-05T17:31:20Z")

</div>

Sorry you are having a rough onboarding experience! We will help, and if there’s anything we can take away to improve the onboarding after helping , we’ll do so!

> [@Domenico](#):
>
> opam list shows core, base, and utop.  
> I try to use # require “base”;; does not work.  
> I try to create a .ocamlinit file, does not work.  
> I use dune build with core and base both in the dune file

Could you please post the textual output you get after these commands, and gives details (e.g., about where you have created the .ocamlinit file)?

Also, could you confirm you followed these installation instructions for windows ? [Install OCaml](https://ocaml.org/install#windows)

---

<div class="post-metadata">

**Author:** ![Domenico](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/domenico/32/5966_2.png) [@Domenico](https://discuss.ocaml.org/u/Domenico)\
**Post date:** [May 5, 2025, 6:28pm UTC](https://discuss.ocaml.org/t/core-and-base-unbound-modules/16607/3 "2025-05-05T18:28:19Z")

</div>

Hi, thank you!

- I did install ocaml using that webpage’s instructions and have been coding and able to run ocaml without packages just fine. However, now that I’m trying to get more advanced I am trying to get these packages and that has been my roadblock

- The .ocamlinit file is in my C:\Users\User\_Name directory

- dune build will output :  
File “bin/main.ml”, line 1, characters 0-9:  
1 | open Base;;  
^^^^^^^^^  
Error (warning 33 [unused-open]): unused open Base.  
File “test/test\_test.ml”, line 1, characters 0-9:  
1 | open Base;;  
^^^^^^^^^  
Error (warning 33 [unused-open]): unused open Base.  
PS C:\Users\Dominic\Desktop\Summer Learning\OCaml\test\> dune runtest  
File “test/test\_test.ml”, line 1, characters 0-9:  
1 | open Base;;  
^^^^^^^^^  
Error (warning 33 [unused-open]): unused open Base.

- trying to run my code with utop after doing # #require “base”; using shift enter exits here:  
utop # open Base;;  
Error: Unbound module Base  
─( 13:14:52 )─\< command 12 \>────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─  
utop # open Core;;  
Error: Unbound module Core  
─( 14:27:25 )─\< command 13 \>────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─utop #

---

<div class="post-metadata">

**Author:** ![yawaramin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yawaramin/32/3384_2.png) [@yawaramin](https://discuss.ocaml.org/u/yawaramin)\
**Post date:** [May 5, 2025, 7:02pm UTC](https://discuss.ocaml.org/t/core-and-base-unbound-modules/16607/4 "2025-05-05T19:02:45Z")

</div>

Note: please use triple-backticks to surround code samples to format them correctly. Eg

```auto
utop # open Base;;

```

> - The .ocamlinit file is in my C:\Users\User\_Name directory

I am fairly sure this is not correct. It should be something like `%USERPROFILE%\AppData`. But I’m unable to find any documentation on this. I recommend experimenting a bit to see what works.

> `Error (warning 33 [unused-open]): unused open Base.`

This is correct. You opened the module but didn’t use it in the file so far, hence the warning. The warning goes away once you start using the stuff defined in `Base`.

> `utop # open Base;;`  
> `Error: Unbound module Base`

This is also correct. You didn’t ‘require’ the library before trying to open its module. Try:

```auto
$ utop -require base
utop # open Base;;;

```

EDIT: related issue? [utop/init.ml does not respect XDG on Windows · Issue #451 · ocaml-community/utop · GitHub](https://github.com/ocaml-community/utop/issues/451)

---

<div class="post-metadata">

**Author:** ![Domenico](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/domenico/32/5966_2.png) [@Domenico](https://discuss.ocaml.org/u/Domenico)\
**Post date:** [May 5, 2025, 7:40pm UTC](https://discuss.ocaml.org/t/core-and-base-unbound-modules/16607/5 "2025-05-05T19:40:00Z")

</div>

```auto
PS C:\Users\User_Name\Desktop\test> (& opam env) -split '\r?\n' | ForEach-Object { Invoke-Expression $_ }
PS C:\Users\User_Name\Desktop\test> utop -require base
─( 15:33:57 )─< command 0 >────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # open Base;;
─( 15:34:11 )─< command 1 >─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─utop #         
( 15:34:23 )─< command 0 >─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # open Base;;
Error: Unbound module Base
─( 15:34:23 )─< command 1 >─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # open Core;;
Error: Unbound module Core
─( 15:34:24 )─< command 2 >─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop #
3+4 ;;
- : int = 7
─( 15:34:24 )─< command 3 >─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # 
8 / 3 ;; 
- : int = 2
─( 15:34:24 )─< command 4 >─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop #
3.5 +. 6. ;;
- : float = 9.5
─( 15:34:24 )─< command 5 >─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop #
3*5>14 ;;
- : bool = true
─( 15:34:24 )─< command 6 >─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop #
let square x = x*x ;;
val square : int -> int = <fun>
─( 15:34:24 )─< command 7 >─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop #
square 2 ;;
- : int = 4
─( 15:34:24 )─< command 8 >─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop #
square (square 2) ;;
- : int = 16
─( 15:34:24 )─< command 9 >─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop #
let ratio x y =
  Float.of_int x /. Float.of_int y ;;
val ratio : int -> int -> float = <fun>
─( 15:34:25 )─< command 10 >────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # 
ratio 4 7 ;;
- : float = 0.5714285714285714
─( 15:34:25 )─< command 11 >────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─utop #        

```

I get an output but the modules are still unbound.

Also in reference to

`This is correct. You opened the module but didn’t use it in the file so far, hence the warning. The warning goes away once you start using the stuff defined in `

I heard this as well but `$ dune runtest` or `$ dune exec` test does not output the code like if I were to run it without `core` and` base` – is this expected?

---

<div class="post-metadata">

**Author:** ![yawaramin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yawaramin/32/3384_2.png) [@yawaramin](https://discuss.ocaml.org/u/yawaramin)\
**Post date:** [May 5, 2025, 8:39pm UTC](https://discuss.ocaml.org/t/core-and-base-unbound-modules/16607/6 "2025-05-05T20:39:36Z")

</div>

```auto
─( 15:33:57 )─< command 0 >────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # open Base;;
─( 15:34:11 )─< command 1 >─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─utop #         
( 15:34:23 )─< command 0 >─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # open Base;;
Error: Unbound module Base

```

I don’t understand this output. You opened `Base` twice, the first time it worked and the second time it didn’t? Did you edit the utop output somehow?

> I heard this as well but `$ dune runtest` or `$ dune exec` test does not output the code like if I were to run it without `core` and` base` – is this expected?

I don’t know what’s in the test so I don’t know what the output should be. Can you try this:

```auto
$ utop -require base
utop # open Base;;
utop # Fn.non;;

```

It should output the signature of [base v0.15.0 · OCaml Package](https://ocaml.org/p/base/v0.15.0/doc/Base/Fn/index.html#val-non)

---

<div class="post-metadata">

**Author:** ![Domenico](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/domenico/32/5966_2.png) [@Domenico](https://discuss.ocaml.org/u/Domenico)\
**Post date:** [May 5, 2025, 9:22pm UTC](https://discuss.ocaml.org/t/core-and-base-unbound-modules/16607/7 "2025-05-05T21:22:41Z")

</div>

```auto
(*Test Program*)
open Base;;
open Core;;

3+4 ;;

8 / 3 ;; 

3.5 +. 6. ;; 

3*5>14 ;;

let square x = x*x ;;

square 2 ;;

square (square 2) ;;

let ratio x y =
  Float.of_int x /. Float.of_int y ;;

ratio 4 7 ;; 

```

I was able to get outputs for this program before I added core and base but now it just gives the unused error. Only when I try to run the dune build

> I don’t understand this output. You opened `Base` twice, the first time it worked and the second time it didn’t? Did you edit the utop output somehow?

The output is first when I open base with utop and then secondly when I try to run my program by pressing shift + enter

This is the output of what you asked:

```PS
───────────────────────────────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────┬──────────────────────────────────────────────────────────────────────────────────── │ Welcome to utop version 2.15.0 (using OCaml version 5.3.0)! │ └─────────────────────────────────────────────────────────────┘

Type #utop_help for help about using utop.

─( 17:17:31 )─< command 0 >────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # open Base;;
─( 17:17:31 )─< command 1 >────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # Fn.non;;
- : ('a -> bool/2) -> 'a -> bool/2 = <fun>

```

---

<div class="post-metadata">

**Author:** ![yawaramin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yawaramin/32/3384_2.png) [@yawaramin](https://discuss.ocaml.org/u/yawaramin)\
**Post date:** [May 5, 2025, 10:10pm UTC](https://discuss.ocaml.org/t/core-and-base-unbound-modules/16607/8 "2025-05-05T22:10:57Z")

</div>

So…everything is working then. The outputs are exactly as expected. `Base` is loaded. You’re getting the ‘unused’ error in your test program because you’re not actually _using_ anything from `Base`. All the operations and definitions in the test program are using basic arithmetic with ints and floats. If you do something like `let is = Fn.non not;;` then you will be using something from `Base` and the ‘unused’ warning will go away.

Btw, `Base` is Jane Street’s portable, minimal version of their standard library. `Core` has a bunch of extra stuff in it that’s not very portable so they recommend that most people use `Base` unless they actually need something from `Core`.

---

<div class="post-metadata">

**Author:** ![Frederic\_Loyer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/frederic_loyer/32/3472_2.png) [@Frederic\_Loyer](https://discuss.ocaml.org/u/Frederic_Loyer)\
**Post date:** [May 5, 2025, 10:40pm UTC](https://discuss.ocaml.org/t/core-and-base-unbound-modules/16607/9 "2025-05-05T22:40:28Z")

</div>

We can use `open!` instead of `open`.

This suppress the unused warning.

---

<div class="post-metadata">

**Author:** ![Domenico](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/domenico/32/5966_2.png) [@Domenico](https://discuss.ocaml.org/u/Domenico)\
**Post date:** [May 5, 2025, 11:21pm UTC](https://discuss.ocaml.org/t/core-and-base-unbound-modules/16607/10 "2025-05-05T23:21:04Z")

</div>

Ah I see, I am not sure how I was getting outputs of the mathematical operations before… I may have gotten it mixed up in my head. I have added some Base functions and now I can execute and build the program. As well as some print statements.

Thanks for your patience!

> Btw, `Base` is Jane Street’s portable, minimal version of their standard library. `Core` has a bunch of extra stuff in it that’s not very portable so they recommend that most people use `Base` unless they actually need something from `Core`.

Will note this, I have heard a lot of complaints about this book because they start you off my installing core when for the most part you use base in the beginning.

---

<div class="post-metadata">

**Author:** ![Leonidas](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/leonidas/32/4039_2.png) [@Leonidas](https://discuss.ocaml.org/u/Leonidas)\
**Post date:** [May 6, 2025, 12:35pm UTC](https://discuss.ocaml.org/t/core-and-base-unbound-modules/16607/11 "2025-05-06T12:35:44Z")

</div>

> [@Domenico](#):
>
> I have heard a lot of complaints about this book because they start you off my installing core when for the most part you use base in the beginning.

I think the book was originally written when there was only `Core`. `Base` came later as a more minimal and more portable, stand-alone foundation for `Core`.
