# Private subpackages

**URL:** <https://discourse.julialang.org/t/private-subpackages/83449>\
**Category:** General Usage\
**Created:** [June 28, 2022, 10:16am UTC](https://discourse.julialang.org/t/private-subpackages/83449 "2022-06-28T10:16:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![simsurace](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simsurace/32/30216_2.png) [@simsurace](https://discourse.julialang.org/u/simsurace)\
**Post date:** [June 28, 2022, 10:16am UTC](https://discourse.julialang.org/t/private-subpackages/83449/1 "2022-06-28T10:16:46Z")

</div>

I have a private (unregistered, closed-source) package. Now I would like to split part of that package into a separate subpackage, i.e. a Julia package that lives in a sub-folder of my current main package, but has separate dependencies, tests, version etc.

Can I use the Julia package manager to point to the subpackage, or do I have to treat the sub-package as a regular submodule by `include("SubPackage/src/SubPackage.jl"); using .SubPackage?` I would prefer to have the convenience of SemVer by using the package manager. Does this require a local registry? If yes, is it possible to put that into the repo of the main package in order to keep the main package self-contained, i.e. all dependencies can be resolved without referring to any extra files outside the main package root folder?

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [June 28, 2022, 11:31am UTC](https://discourse.julialang.org/t/private-subpackages/83449/2 "2022-06-28T11:31:59Z")

</div>

> [@simsurace](#):
>
> Can I use the Julia package manager to point to the subpackage,

Yes, you can. When adding by URL or path, append a colon and the directory name. If you develop by path you can just provide the path into the subdirectory.

> [@simsurace](#):
>
> I would prefer to have the convenience of SemVer by using the package manager. Does this require a local registry?

There are some things you can do without but for the full power of the package manager you want your packages to be in a registry.

> [@simsurace](#):
>
> If yes, is it possible to put that into the repo of the main package in order to keep the main package self-contained, i.e. all dependencies can be resolved without referring to any extra files outside the main package root folder?

I wouldn’t exactly recommend it, but it is indeed possible. The technical requirement of a registry is that it contains a `Registry.toml` at the top of a git repository and some area for the registry data files. With existing tooling the data files are structured in the same way as in the General registry (`<package_initial>/<package_name>/*.toml`).

The major drawback of doing it this way is that you will get a full copy of your package code in `~/.julia/registries/your_registry`, not only the registry information.

Similarly, if you have the main package at the top of the repository and the subpackage in a subdirectory, the main package will contain (an unused) copy of your subpackage.
