# (Sub)module not found in test when using dune

**URL:** <https://discuss.ocaml.org/t/sub-module-not-found-in-test-when-using-dune/13681>\
**Category:** Learning\
**Tags:** dune\
**Created:** [December 19, 2023, 10:09pm UTC](https://discuss.ocaml.org/t/sub-module-not-found-in-test-when-using-dune/13681 "2023-12-19T22:09:10Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![jbe](https://avatars.discourse-cdn.com/v4/letter/j/f6c823/32.png) [@jbe](https://discuss.ocaml.org/u/jbe)\
**Post date:** [December 19, 2023, 10:38pm UTC](https://discuss.ocaml.org/t/sub-module-not-found-in-test-when-using-dune/13681/3 "2023-12-19T22:38:10Z")

</div>

From that other thread:

> [@Using Modules (15 characters long now)](https://discuss.ocaml.org/t/using-modules-15-characters-long-now/13630/2):
>
> In this case suppose you have `lib/` which contains:
> 
> ```auto
> dune
> mymodule.ml
> othermodule.ml
> 
> ```
> 
> And `dune` contains:
> 
> ```auto
> (library
> (name lib))
> 
> ```
> 
> Then the modules will be available as: `Lib.Mymodule` and `Lib.Othermodule`.

I do have a `lib/dune` file that says `(library (name mylib))`, so that would mean the module in `lib/mylib.ml` would be available as `Mylib.Mylib` and the module in `lib/mymod.ml` would be available as `Mylib.Mymod`. But that isn’t the case, i.e. this fails:

```auto
let _ = assert (Mylib.Mylib.one = 1)
let _ = assert (Mylib.Mymod.two = 2)

```

Instead, if I change `(library (name mylib))` to `(library (name foo))` (and modify `test/dune` accordingly), then these are suddenly available as `Foo.Mylib` and `Foo.Mymod`, i.e. this works:

```auto
let _ = assert (Foo.Mylib.one = 1)
let _ = assert (Foo.Mymod.two = 2)

```

Why does the first fail and the second work?

---

_[View the full topic](https://discuss.ocaml.org/t/sub-module-not-found-in-test-when-using-dune/13681)._
