# Creating and publishing my Very First Package

**URL:** <https://discourse.julialang.org/t/creating-and-publishing-my-very-first-package/69831>\
**Category:** New to Julia\
**Tags:** question, package, github\
**Created:** [October 15, 2021, 2:22pm UTC](https://discourse.julialang.org/t/creating-and-publishing-my-very-first-package/69831 "2021-10-15T14:22:45Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Niall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niall/32/22517_2.png) [@Niall](https://discourse.julialang.org/u/Niall)\
**Post date:** [October 15, 2021, 2:22pm UTC](https://discourse.julialang.org/t/creating-and-publishing-my-very-first-package/69831/1 "2021-10-15T14:22:45Z")

</div>

Hi. I’m climbing up the wall a bit here. I’ve never created a package before, so I want to create one, simply to work out how to work with packages, but I’ve come to a complete standstill. I’ve viewed about 20 different YouTube tutorials and read several online texts on generating and publishing packages, but can’t get any of them to work for me.

I want to generate a package at an arbitrary location (not necessarily ~/.julia/dev), and publish it to a GitHub repository. I can generate a local package using PkgTemplates, and I can create a GitHub repository, but I can’t seem to link the two. When I try to add the local package, I get the GitHub message “The repository does not seem to exist anymore”.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [October 15, 2021, 2:23pm UTC](https://discourse.julialang.org/t/creating-and-publishing-my-very-first-package/69831/2 "2021-10-15T14:23:58Z")

</div>

Try this:

[https://m3g.github.io/JuliaNotes.jl/stable/new\_package/](https://m3g.github.io/JuliaNotes.jl/stable/new_package/)

---

<div class="post-metadata">

**Author:** ![Niall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niall/32/22517_2.png) [@Niall](https://discourse.julialang.org/u/Niall)\
**Post date:** [October 15, 2021, 2:24pm UTC](https://discourse.julialang.org/t/creating-and-publishing-my-very-first-package/69831/3 "2021-10-15T14:24:41Z")

</div>

Will do - thanks!

---

<div class="post-metadata">

**Author:** ![jlperla](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlperla/32/34332_2.png) [@jlperla](https://discourse.julialang.org/u/jlperla)\
**Post date:** [October 15, 2021, 2:31pm UTC](https://discourse.julialang.org/t/creating-and-publishing-my-very-first-package/69831/4 "2021-10-15T14:31:36Z")

</div>

> **[Packages, Testing, and Continuous Integration](https://julia.quantecon.org/software_engineering/testing.html)**
>
> This website presents a set of lectures on quantitative economic modeling, designed and written by Jesse Perla, Thomas J. Sargent and John Stachurski. The language instruction is Julia.

That had what we hope is a very beginner friendly intro to this - albeit there isn’t instructions for getting documentation building etc. It also builds on the github lecture [11. GitHub, Version Control and Collaboration — Quantitative Economics with Julia](https://julia.quantecon.org/software_engineering/version_control.html)

---

<div class="post-metadata">

**Author:** ![Niall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niall/32/22517_2.png) [@Niall](https://discourse.julialang.org/u/Niall)\
**Post date:** [October 15, 2021, 2:58pm UTC](https://discourse.julialang.org/t/creating-and-publishing-my-very-first-package/69831/5 "2021-10-15T14:58:12Z")

</div>

OK many thanks - that seems to have worked fine, but since those instructions put the package in the .julia/dev directory, I had to do a bit extra. In total, what I did was the folloiwng:

**Create an _EMPTY_ repository on github, with my package name followed by `.jl`**

**Create the `.julia/dev/MyPackage` directory with the content inside:**  
using PkgTemplates  
tpl = Template(user=“lmiq”)  
tpl(“MyPackage”)

**Navigate to the package directory and push content to repository for the first time:**  
cd ~/.julia/dev/MyPackage  
git push --set-upstream origin master

**Go to github and clone the new repository into the directory where I actually want it**  
At this stage I can delete the package from .julia/dev

---

<div class="post-metadata">

**Author:** ![Niall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niall/32/22517_2.png) [@Niall](https://discourse.julialang.org/u/Niall)\
**Post date:** [October 15, 2021, 2:59pm UTC](https://discourse.julialang.org/t/creating-and-publishing-my-very-first-package/69831/6 "2021-10-15T14:59:09Z")

</div>

Thanks @jperla, I’ll give that a try next. :-))

---

<div class="post-metadata">

**Author:** ![Niall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niall/32/22517_2.png) [@Niall](https://discourse.julialang.org/u/Niall)\
**Post date:** [October 15, 2021, 5:30pm UTC](https://discourse.julialang.org/t/creating-and-publishing-my-very-first-package/69831/7 "2021-10-15T17:30:59Z")

</div>

OK, many thanks to @lmiq and @jlperla . To anyone coming after, I’ve now solved my problem by creating the following little Julia file which I open in VSCode whenever I want to create a new package. I can then do everything from within VSC (and github):

```julia
# In GitHub:
# Create empty (!) repository PackageName.jl
# In Julia:
using PkgTemplates
t = Template(user="NiallPalfreyman")
t("PackageName")
# In cmd:
# cd ~/.julia/dev/PackageName
# git push --set-upstream origin master
# In GitHub:
# Clone repository PackageName.jl to required local directory
# In Windows:
# Delete PackageName from ~/.julia/dev

```

---

<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:** [October 15, 2021, 9:09pm UTC](https://discourse.julialang.org/t/creating-and-publishing-my-very-first-package/69831/8 "2021-10-15T21:09:58Z")

</div>

This ?

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

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [October 16, 2021, 1:38am UTC](https://discourse.julialang.org/t/creating-and-publishing-my-very-first-package/69831/9 "2021-10-16T01:38:47Z")

</div>

For a quick taste try this [Why Julia - Package Development in Under 4 Minutes - YouTube](https://www.youtube.com/watch?v=vVywlAgyedI&t=1s)

---

<div class="post-metadata">

**Author:** ![Niall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niall/32/22517_2.png) [@Niall](https://discourse.julialang.org/u/Niall)\
**Post date:** [October 16, 2021, 5:11am UTC](https://discourse.julialang.org/t/creating-and-publishing-my-very-first-package/69831/10 "2021-10-16T05:11:24Z")

</div>

Thanks very much everyone - those are great new resources. There is just one thing that is still puzzling me. In all of these references they say that if you start Julia from within a particular folder like, say, the desktop, then `generate` will create the package in that folder. Yet that just does not seem to be the case for me. No matter where I start Julia, it always creates the package in ~/.julia/dev. Is this something I’ve omitted in my installation somehow?

---

<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:** [October 16, 2021, 6:03am UTC](https://discourse.julialang.org/t/creating-and-publishing-my-very-first-package/69831/11 "2021-10-16T06:03:07Z")

</div>

Are you using `Pkg.generate()` or `PkgTemplates.generate()` ?

The default for `Pkg.generate()` is to create a folder in the current folder.  
The default for `PkgTemplates.generate()` is to create a folder in `~/.julia/dev` (`Pkg.devdir()`)

The interactive menu of `PkgTemplates` allows you to customize `dir`.

---

<div class="post-metadata">

**Author:** ![Niall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niall/32/22517_2.png) [@Niall](https://discourse.julialang.org/u/Niall)\
**Post date:** [October 16, 2021, 7:47am UTC](https://discourse.julialang.org/t/creating-and-publishing-my-very-first-package/69831/12 "2021-10-16T07:47:12Z")

</div>

Ah. 😀 That would explain it - thanks. I’m using PkgTemplates.generate(). Mystery solved!
