# Can someone please explain the \`lib\` directory?

**URL:** <https://discourse.julialang.org/t/can-someone-please-explain-the-lib-directory/84238>\
**Category:** General Usage\
**Tags:** question\
**Created:** [July 14, 2022, 7:02pm UTC](https://discourse.julialang.org/t/can-someone-please-explain-the-lib-directory/84238 "2022-07-14T19:02:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cadojo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cadojo/32/25328_2.png) [@cadojo](https://discourse.julialang.org/u/cadojo)\
**Post date:** [July 14, 2022, 7:02pm UTC](https://discourse.julialang.org/t/can-someone-please-explain-the-lib-directory/84238/1 "2022-07-14T19:02:36Z")

</div>

I see a `lib` directory in [GitHub - JuliaArrays/ArrayInterface.jl: Designs for new Base array interface primitives, used widely through scientific machine learning (SciML) and other organizations](https://github.com/JuliaArrays/ArrayInterface.jl) and [GitHub - SciML/Optimization.jl: Local, global, and beyond optimization for scientific machine learning (SciML)](https://github.com/SciML/Optimization.jl/). The `lib` directory seems to hold other Julia “sub-packages”, but how are they accessible to the user? And why are they accessible to the user? Does `Pkg` look for sub packages to the `lib` directory, and if so, how do those sub-packages differ from sub-modules in the `src` directory?

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [July 14, 2022, 8:27pm UTC](https://discourse.julialang.org/t/can-someone-please-explain-the-lib-directory/84238/2 "2022-07-14T20:27:15Z")

</div>

I think this `lib` directory is more convention than anything else. HDF5.jl has a [`filters`](https://github.com/JuliaIO/HDF5.jl/tree/master/filters) directory containing filter sub-packages.

Perhaps the larger explanation that you are looking for is regarding subdirectory packages.

> [@Usage of subdirectories to store multiple packages in a single repo](https://discourse.julialang.org/t/usage-of-subdirectories-to-store-multiple-packages-in-a-single-repo/55534):
>
> According to [Registrator.jl#287](https://github.com/JuliaRegistries/Registrator.jl/pull/287) and [Pkg.jl#1422](https://github.com/JuliaLang/Pkg.jl/pull/1422) merged pull requests, several packages can now be organized as subdirectories of a single repo. However, I have not been able to found any detailed docs, which would explain how to use this new functionality. As a result, I would like to ask a number of questions here, on discourse. How are the subdirectories supposed to be organized? Must each of the subdirectories have the normal package structure with Project.toml, Manifest.toml, ./src, ./test…

Unlike modules in the `src` directory, these other folders are packages in their own right. They have their own Project.toml with an UUID. They just happen to be housed within the same git repository as the parent package.

`Pkg` does not have an automatic way of looking into a `lib` directory. One could add the lib directory as a place to load packages from via the environment variable [`JULIA_LOAD_PATH`](https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_LOAD_PATH) or the Julia variable [`Base.LOAD_PATH`](https://docs.julialang.org/en/v1/base/constants/#Base.LOAD_PATH).

The way HDF5.jl loads up the subpackages is via `Pkg.develop` or `]dev` which allows you specify a local file system path to a package.

> <https://github.com/JuliaIO/HDF5.jl/blob/7999d1a261cb1c950f026946b4405686281636da/test/runtests.jl#L4-L8>

ArrayInterface.jl seems to do something similar:

> <https://github.com/JuliaArrays/ArrayInterface.jl/blob/cb39428caa0a548f727e8f8e485e0d85d6f1a7de/test/runtests.jl#L5-L8>

`Pkg.develop` will add these packages to the project’s Manifest.toml which will remember the relative paths. However, the Manifest.toml is not usually tracked by git for a library package like those you mentioned.
