# Several questions that arise during learning package development

**URL:** <https://discourse.julialang.org/t/several-questions-that-arise-during-learning-package-development/110399>\
**Category:** General Usage\
**Tags:** question, package\
**Created:** [February 19, 2024, 11:49am UTC](https://discourse.julialang.org/t/several-questions-that-arise-during-learning-package-development/110399 "2024-02-19T11:49:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [February 19, 2024, 11:49am UTC](https://discourse.julialang.org/t/several-questions-that-arise-during-learning-package-development/110399/1 "2024-02-19T11:49:40Z")

</div>

I’m trying to understand the organization mechanism of Julia packages and seeking for a good workflow that is suitable for me for package development. My expected learning roadmap is to firstly create a minimal package from scratch locally and invoke it from another project, and after that learn how to upload it to GitHub and register it and so on.

Up to now, I have just created a package named `MyPackage` using command `generate` under Julia’s package mode and the folder `MyPackage` has appeared in my working directory named `myPkgDev`.

Now, I’d like to ask the following several questions:

1. I’ve learnt there are several ways to invoke this package such as `activate`, `dev` or `add` it, but what are the differences between them?
2. It seems that to `add` a local package I need to make it a git repository first, so I executed `cd MyPackage`, `git init`, `git add .` and `git commit -a -m "Initial package structure."` in sequence and executed `add ./MyPackage` under Julia package mode in the original working directory. No surprise, it worked, but my question here is, why is the `add`-ing package process so slow? (I can understand the slow process of adding a registered package from the network, but why is adding the smallest local package so slow? What exactly happened in the process?) And why are there 11 dependencies for a package that only has `Hello World!`?

```julia
(@v1.9) pkg> add ./MyPackage
     Cloning git-repo `D:\myPkgDev\MyPackage`
    Updating git-repo `D:\myPkgDev\MyPackage`
    Updating registry at `C:\Users\Name\.julia\registries\General.toml`
   Resolving package versions...
    Updating `C:\Users\Name\.julia\environments\v1.9\Project.toml`
  [2fed5cd1] + MyPackage v0.1.0 `D:\myPkgDev\MyPackage#main`
    Updating `C:\Users\Name\.julia\environments\v1.9\Manifest.toml`        
  [2fed5cd1] + MyPackage v0.1.0 `D:\myPkgDev\MyPackage#main`
Precompiling project...
  ✓ MyPackage
  11 dependencies successfully precompiled in 159 seconds. 229 already precompiled.
  1 dependency precompiled but a different version is currently loaded. Restart julia to access the new version

```

1. It would be nice if you could recommend some complete tutorials or good workflows for Julia package development.

Thanks! 🙏

---

<div class="post-metadata">

**Author:** ![SteffenPL](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steffenpl/32/206270_2.png) [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Post date:** [February 19, 2024, 1:50pm UTC](https://discourse.julialang.org/t/several-questions-that-arise-during-learning-package-development/110399/2 "2024-02-19T13:50:08Z")

</div>

One way to start developing a new package is to use [JuliaCI/PkgTemplates.jl](https://github.com/JuliaCI/PkgTemplates.jl).

_I don’t know why adding a local packge was slow in your case…_

To the other questions:

1. First of all, `activate` is quite different from `add` and `dev`.

- `activate` just enters a new or existing project environment and allows you to resolve dependencies for different projects independently.
- `add` will add a new dependency to the currently activated project. However, it kind of assumes that you are not changing the code of the added package.
- `dev` is like add, but with the extra that it will put the added package into a nice location (if not already a local path) and it accepts changes. You could `dev` a package from other people and make local changes to it.

1. With package templates you can shorten this process by just doing:

```julia
using PkgTemplates
Template(interactive=true)("MyPkg")

```

It takes time at the first run, but it is worth it.

1. Maybe this video and tutorial is helpful: [How to develop a Julia package (julialang.org)](https://julialang.org/contribute/developing_package/)

A few links for reading are of course [3. Managing Packages · Pkg.jl (julialang.org)](https://pkgdocs.julialang.org/v1/managing-packages/)  
and I also like this source: [Writing your code (modernjuliaworkflows.github.io)](https://modernjuliaworkflows.github.io/pages/writing/writing/#local_packages).

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [February 19, 2024, 2:03pm UTC](https://discourse.julialang.org/t/several-questions-that-arise-during-learning-package-development/110399/3 "2024-02-19T14:03:35Z")

</div>

Thank you for your generous answer! And happy anniversary of joining the community! 🤝🤝

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [February 19, 2024, 3:17pm UTC](https://discourse.julialang.org/t/several-questions-that-arise-during-learning-package-development/110399/4 "2024-02-19T15:17:56Z")

</div>

Yet another tutorial on package development, that include documentation, testing, registration…

> **[11 - Developing Julia packages](https://syl1.gitbook.io/julia-language-a-concise-tutorial/language-core/11-developing-julia-packages)**

---

<div class="post-metadata">

**Author:** ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Post date:** [February 19, 2024, 3:35pm UTC](https://discourse.julialang.org/t/several-questions-that-arise-during-learning-package-development/110399/5 "2024-02-19T15:35:24Z")

</div>

My favorite resource on the topic:  
[jkrumbiegel.com - Pkg.jl and Julia Environments for Beginners](https://jkrumbiegel.com/pages/2022-08-26-pkg-introduction/)

(Also, some follow-up discussion in [this post](https://discourse.julialang.org/t/response-to-pkg-jl-and-julia-environments-for-beginners-by-jules/86552/3).)

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [February 20, 2024, 1:45pm UTC](https://discourse.julialang.org/t/several-questions-that-arise-during-learning-package-development/110399/7 "2024-02-20T13:45:46Z")

</div>

Thank you all for the learning resources, they are really very useful! In particular this one: [jkrumbiegel.com - Pkg.jl and Julia Environments for Beginners](https://jkrumbiegel.com/pages/2022-08-26-pkg-introduction/), I have to say, is right up my alley at the moment. 👍 👍

---

<div class="post-metadata">

**Author:** ![GHTaarn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ghtaarn/32/216007_2.png) [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)\
**Post date:** [February 20, 2024, 2:14pm UTC](https://discourse.julialang.org/t/several-questions-that-arise-during-learning-package-development/110399/8 "2024-02-20T14:14:44Z")

</div>

I saw that none of the above links mention LocalRegistry, I find this to be a very useful stepping stone between having a local package and registration in the General registry. It is also nice if you have code that is not suitable for the General registry (either because it is confidential, experimental or too specialised).

> **[GitHub - GunnarFarneback/LocalRegistry.jl: Create and maintain local...](https://github.com/GunnarFarneback/LocalRegistry.jl/)**
>
> Create and maintain local registries for Julia packages. - GunnarFarneback/LocalRegistry.jl

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [February 20, 2024, 2:37pm UTC](https://discourse.julialang.org/t/several-questions-that-arise-during-learning-package-development/110399/9 "2024-02-20T14:37:24Z")

</div>

Good stuff! I’ll look into it later! Thank you! 🤝 🤝
