# How to start writing a new Julia package?

**URL:** <https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864>\
**Category:** General Usage\
**Tags:** package, github\
**Created:** [March 23, 2017, 5:13pm UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864 "2017-03-23T17:13:22Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![sbohor3](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@sbohor3](https://discourse.julialang.org/u/sbohor3)\
**Post date:** [March 24, 2017, 10:37pm UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/21 "2017-03-24T22:37:00Z")

</div>

@ChrisRackauckas: When I ran my first test on the package, it failed. What could be a possible error for the tests to fail?  
``  
test\runtests.jl, in expression starting on line 5```

Where in line 5, I have `@test 1 == 2`

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [March 24, 2017, 10:38pm UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/22 "2017-03-24T22:38:38Z")

</div>

I guess the problem is that 1 is not equal to 2 😉

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [March 24, 2017, 10:39pm UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/23 "2017-03-24T22:39:03Z")

</div>

Oh, those docs use mkdocs? Might need to write an up to date tutorial for the native render. Essentially, you just define the documentation structure like here:

[https://github.com/JuliaDiffEq/DiffEqDocs.jl/blob/master/docs/make.jl](https://github.com/JuliaDiffEq/DiffEqDocs.jl/blob/master/docs/make.jl)

That setup should build it without mkdocs.

Should open an issue to Documenter.jl to document the native render.

---

<div class="post-metadata">

**Author:** ![sbohor3](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@sbohor3](https://discourse.julialang.org/u/sbohor3)\
**Post date:** [March 24, 2017, 10:39pm UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/24 "2017-03-24T22:39:43Z")

</div>

@giordano: Lol, yes it was. Thanks.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [March 24, 2017, 10:39pm UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/25 "2017-03-24T22:39:46Z")

</div>

Look at the file `test\runtests.jl`. That’s where the tests go. You’ll notice that by default it makes the test `@test 1==2` which will fail. You’ll want to replace that with your testing code.

---

<div class="post-metadata">

**Author:** ![sbohor3](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@sbohor3](https://discourse.julialang.org/u/sbohor3)\
**Post date:** [March 24, 2017, 10:42pm UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/26 "2017-03-24T22:42:32Z")

</div>

> [@ChrisRackauckas](#):
>
> mkdocs

Do I need to install this separately? Thanks.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [March 24, 2017, 10:44pm UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/27 "2017-03-24T22:44:17Z")

</div>

> [@sbohor3](#):
>
> Do I need to install this separately? Thanks.

Yes, if you go the mkdocs route. (I prefer the native HTML render route, but I guess it’s not documented yet? So do what you think is best. I think it’s just `pip install mkdocs`)

---

<div class="post-metadata">

**Author:** ![sbohor3](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@sbohor3](https://discourse.julialang.org/u/sbohor3)\
**Post date:** [March 24, 2017, 10:47pm UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/28 "2017-03-24T22:47:59Z")

</div>

@ChrisRackauckas: So, this is a `python` package then??  
Iis this where we refer to: [http://www.mkdocs.org/](http://www.mkdocs.org/) ?

---

<div class="post-metadata">

**Author:** ![sbohor3](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@sbohor3](https://discourse.julialang.org/u/sbohor3)\
**Post date:** [March 24, 2017, 10:51pm UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/29 "2017-03-24T22:51:06Z")

</div>

@ChrisRackauckas: Another quick question. How do I store data (like .csv) within a package so that we use the data as sample for the test? Is there a standard practice?  
Thanks.

---

<div class="post-metadata">

**Author:** ![sbohor3](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@sbohor3](https://discourse.julialang.org/u/sbohor3)\
**Post date:** [March 25, 2017, 4:45am UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/30 "2017-03-25T04:45:23Z")

</div>

@ChrisRackauckas: How do I clone my Github repo package to another computer? I have two-factor authentication enabled in Github. Using just `Pkg.clone()` did not work. Thanks.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [March 25, 2017, 5:41am UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/31 "2017-03-25T05:41:03Z")

</div>

> [@sbohor3](#):
>
> So, this is a python package then??

Yes, mkdocs is. You can use the HTML render as explained above in order to not use mkdocs if you want though.

> [@sbohor3](#):
>
> How do I store data (like .csv) within a package so that we use the data as sample for the test? Is there a standard practice?

I think it’s quite common to make an `examples` folder in the top level for example datasets, Jupyter notebooks, etc.

> [@sbohor3](#):
>
> How do I clone my Github repo package to another computer? I have two-factor authentication enabled in Github. Using just Pkg.clone() did not work.

If the repo is public, `Pkg.clone("URL")` should work even without authentication. You will only need to authenticate if the package is private. If that’s the case, then you will likely need to use the Git SSH protocol (use the SSH url).

---

<div class="post-metadata">

**Author:** ![sbohor3](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@sbohor3](https://discourse.julialang.org/u/sbohor3)\
**Post date:** [March 25, 2017, 6:16am UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/32 "2017-03-25T06:16:31Z")

</div>

It is a private repo. I tried to clone it using SSH as well, but did not work. Is there any special commands that I need? Thanks.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [March 25, 2017, 6:24am UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/33 "2017-03-25T06:24:02Z")

</div>

You need to make sure your Git is authenticated. I would recommend trying to do this directly from the Git CLI (or GitKraken) first. You might need to set up an SSH key? (Note when this is properly setup, Julia’s Pkg will work as well since Pkg just calls the Git CLI)

---

<div class="post-metadata">

**Author:** ![sbohor3](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@sbohor3](https://discourse.julialang.org/u/sbohor3)\
**Post date:** [March 25, 2017, 4:24pm UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/34 "2017-03-25T16:24:28Z")

</div>

@ChrisRackauckas: Thanks. When I run the `Pkg.test()` on the cloned package, it throws an error saying **“… is not an installed package”**. Any advice to solve this? Thanks.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [March 25, 2017, 4:31pm UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/35 "2017-03-25T16:31:17Z")

</div>

You need to add dependencies to your REQUIRE file. You’ll find that at the top level.

---

<div class="post-metadata">

**Author:** ![sbohor3](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@sbohor3](https://discourse.julialang.org/u/sbohor3)\
**Post date:** [March 25, 2017, 4:38pm UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/36 "2017-03-25T16:38:41Z")

</div>

I have `julia 0.5` in `REQUIRE` right now. Do I need any other dependencies? Thanks.

---

<div class="post-metadata">

**Author:** ![sbohor3](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@sbohor3](https://discourse.julialang.org/u/sbohor3)\
**Post date:** [March 25, 2017, 5:05pm UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/37 "2017-03-25T17:05:11Z")

</div>

> [@ChrisRackauckas](#):
>
> add dependencies to your REQUIRE fil

OK. I added other packages that my package is dependent on. But, it still says the same error. How do I locally install my package and run `Pkg.test()`

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [March 25, 2017, 5:35pm UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/38 "2017-03-25T17:35:03Z")

</div>

> [@sbohor3](#):
>
> I added other packages that my package is dependent on. But, it still says the same error.

You need to `Pkg.add` the other packages locally. The REQUIRE file is used to get the dependencies, but only when you add your package the first time. Since you’re developing your package, you never cloned it with the packages in the REQUIRE, so it never triggered the downloading of the dependencies. However, from now on cloning it will get the deps.

---

<div class="post-metadata">

**Author:** ![sbohor3](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@sbohor3](https://discourse.julialang.org/u/sbohor3)\
**Post date:** [March 25, 2017, 5:57pm UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/39 "2017-03-25T17:57:32Z")

</div>

> [@ChrisRackauckas](#):
>
> You need to Pkg.add the other packages locally

Yes, I have installed all the packages needed for my package.Still the same problem.

When I generated package using `Pkg.generate()` in the first computer. The package was created in `~\v0.5` without the `.jl` extension on the package name and it worked fine on that computer. However, when I cloned the package from Github to another computer. I see my package folder has `.jl` extension on it. Is that how it should be?

Also, do I need to clone the package to `~\v0.5`? Can I clone it to another location?  
Thanks.

---

<div class="post-metadata">

**Author:** ![Tero\_Frondelius](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tero_frondelius/32/7629_2.png) [@Tero\_Frondelius](https://discourse.julialang.org/u/Tero_Frondelius)\
**Post date:** [March 25, 2017, 6:02pm UTC](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864/40 "2017-03-25T18:02:42Z")

</div>

```julia
julia > Pkg.clone("https:\\...")

```

[Previous page](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864.md?page=1)

[Next page](https://discourse.julialang.org/t/how-to-start-writing-a-new-julia-package/2864.md?page=3)
