Can someone please explain the `lib` directory?

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 and GitHub - SciML/Optimization.jl: Local, global, and beyond optimization for scientific machine learning (SciML). 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?

I think this lib directory is more convention than anything else. HDF5.jl has a filters directory containing filter sub-packages.

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

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 or the Julia variable 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.

ArrayInterface.jl seems to do something similar:

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.