# Adding a local package using the Pkg manager - how to add the path?

**URL:** <https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138>\
**Category:** New to Julia\
**Tags:** question, package\
**Created:** [May 8, 2020, 8:44pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138 "2020-05-08T20:44:25Z")\
**Posts on this page:** 15\
**Page:** 2

<div class="post-metadata">

**Author:** ![roi.holtzman](https://avatars.discourse-cdn.com/v4/letter/r/f05b48/32.png) [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Post date:** [May 8, 2020, 10:52pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/21 "2020-05-08T22:52:39Z")

</div>

I am still curious to know how to simply add a path to where julia’s `Pkg` is looking for packages - like `PkgTemplates` does.  
This was be the most simple for me.

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [May 9, 2020, 1:24pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/22 "2020-05-09T13:24:47Z")

</div>

It’s just `dev`ing them like you did, see [here](https://github.com/invenia/PkgTemplates.jl/blob/055f37d720fede4cc4e873a34f683372213cc0ce/src/plugins/develop.jl).

---

<div class="post-metadata">

**Author:** ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Post date:** [May 10, 2020, 3:16pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/23 "2020-05-10T15:16:07Z")

</div>

My guess is that the package was `dev`-ed on your local machine, but `add`ed on the other machine. The difference here is that an added package points to a specific commit, but a dev-ed package looks at every change in the source files and re-compiles the package even without them being committed. Perhaps you had not committed your changes after adding `foo`? In this case adding the package will not get you `foo` but `dev`ing it will. Perhaps `dev` is what you want anyway.

---

<div class="post-metadata">

**Author:** ![roi.holtzman](https://avatars.discourse-cdn.com/v4/letter/r/f05b48/32.png) [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Post date:** [May 12, 2020, 12:38pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/24 "2020-05-12T12:38:37Z")

</div>

Thanks a lot for the explanation!

---

<div class="post-metadata">

**Author:** ![lewis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lewis/32/5217_2.png) [@lewis](https://discourse.julialang.org/u/lewis)\
**Post date:** [August 19, 2022, 3:03pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/25 "2022-08-19T15:03:19Z")

</div>

I realize this is an old thread but the answer seems not quite satisfactory.

I don’t think you can do this with the REPL form of the package manager launched with `]`

You can do it easily with the Pkg set of functions as here:

```julia
using Pkg
Pkg.add(path="/Users/<hiding my name>/Dropbox/Covid Modeling/Covid-ILM")

```

The only additional complication as variously discussed above is that the directory must contain a git repository for the code of the package: you’ll have a hidden directory named .git within the path. And all of the code files will have been added.

And your package at the specific path meets the minimal requirements for being a package: that is there must be a valid `Project.toml` file there. It need not be as complicated as all of the overly elaborate and confusing (almost to the point of being misleading) documentation describes[1]. Look at one of your installed packages and see its Project.toml file. Make a copy and chop away and change it to include the minimum needed. Of course, this file must be tracked in git.

[1] I say this only because the documentation for Pkg and creating packages serves several needs. In particular, it provides direction on how to develop and maintain registered packages–essential documentation, but somewhat makes the tasks of using packages that you’ve written yourself seem more complicated than it is. I think I’ll write the absolute minimal guide to writing your own packages that you never intend to add to Julia’s public registry for packages. I do not mean to say that there is anything wrong with the way Pkg works. It was brilliant and flexible to bootstrap on github (or really any git server for privately shared packages) and many problems suffered by some other languages have been avoided. Hats off–it’s only that comprehensive documentation can make a simpler use case seem harder than it actually is.

---

<div class="post-metadata">

**Author:** ![roi.holtzman](https://avatars.discourse-cdn.com/v4/letter/r/f05b48/32.png) [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Post date:** [August 26, 2022, 8:59am UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/26 "2022-08-26T08:59:30Z")

</div>

Thanks a lot for the explanation!

I had another issue regarding this. I am running this package on two machines, and the home folder is different on these machines.  
To solve this I used `develop ~/myfolder/MyPackage`.

---

<div class="post-metadata">

**Author:** ![lewis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lewis/32/5217_2.png) [@lewis](https://discourse.julialang.org/u/lewis)\
**Post date:** [August 26, 2022, 2:13pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/27 "2022-08-26T14:13:27Z")

</div>

You are adding the package to two different instances of Julia. You can use the appropriate path on each machine.

- Lewis

---

<div class="post-metadata">

**Author:** ![roi.holtzman](https://avatars.discourse-cdn.com/v4/letter/r/f05b48/32.png) [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Post date:** [August 26, 2022, 2:14pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/28 "2022-08-26T14:14:43Z")

</div>

Thanks! But the code is shared on both machines. That is why I want things to be compatible.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [August 26, 2022, 2:15pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/29 "2022-08-26T14:15:39Z")

</div>

It looks like the module is actually called `pendulum`? Is that the reason?

---

<div class="post-metadata">

**Author:** ![roi.holtzman](https://avatars.discourse-cdn.com/v4/letter/r/f05b48/32.png) [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Post date:** [August 26, 2022, 2:54pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/30 "2022-08-26T14:54:54Z")

</div>

no. I am sorry for the confusion: at the moment there is no problem. using `~` to indicate the home folder works great.

---

<div class="post-metadata">

**Author:** ![lewis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lewis/32/5217_2.png) [@lewis](https://discourse.julialang.org/u/lewis)\
**Post date:** [August 26, 2022, 10:23pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/31 "2022-08-26T22:23:08Z")

</div>

Once you’ve used the package manager to install the package on each machine, your code will invoke that package as ‘using mypkg’. Your code will be the same regardless of which machine it runs on. The name space for installed packages doesn’t refer to the file system.

Am I missing something about what you need? If so, Let’s look at that.

- Lewis

---

<div class="post-metadata">

**Author:** ![roi.holtzman](https://avatars.discourse-cdn.com/v4/letter/r/f05b48/32.png) [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Post date:** [August 27, 2022, 7:48pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/32 "2022-08-27T19:48:52Z")

</div>

No, you’re right.  
But since I am `dev`-ing this package, I need to add a path, namely

```julia
] dev ~/src/MyPackage

```

This means that as long as in both machines that package is located at `~/src/MyPackage` everything will work properly.

(The issue was that beforehand I was not sure that `~` would work as indicating the home folder, but now I see that it works).

---

<div class="post-metadata">

**Author:** ![lewis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lewis/32/5217_2.png) [@lewis](https://discourse.julialang.org/u/lewis)\
**Post date:** [August 27, 2022, 9:03pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/33 "2022-08-27T21:03:24Z")

</div>

Fair enough.

I test the work I am doing on my similar local package using Jupyterlab. So, I include the statements

```julia

# Run this when actively modifying the code in the package

**using** Pkg

Pkg **.**** develop**(path**=**"/Users/<myname>/Dropbox/Covid Modeling/Covid-ILM")

```

in a cell in the notebook where I run simple tests. You are correct that I could use ~ to replace the first 2 steps of the above path. I am not clear on how long the “develop” status stays “open”.

Then, I edit away in VS Code.

You could open the REPL, declare you are deving the package before you start a coding session.

---

<div class="post-metadata">

**Author:** ![roi.holtzman](https://avatars.discourse-cdn.com/v4/letter/r/f05b48/32.png) [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Post date:** [August 29, 2022, 3:32pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/34 "2022-08-29T15:32:12Z")

</div>

I was actually wrong here!  
When I `dev` using `~`, it puts in the path to the home folder in a hard-coded way in the `Project.toml` file. This is not what I want since I am using two machines with two different home folder paths.  
I am now trying out adding a relative path. I hope that works well.

---

<div class="post-metadata">

**Author:** ![pxshen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pxshen/32/38776_2.png) [@pxshen](https://discourse.julialang.org/u/pxshen)\
**Post date:** [July 18, 2024, 12:22am UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/35 "2024-07-18T00:22:44Z")

</div>

I prefer `]dev` over `]add` because you don’t have to reinstall the pkg everytime you make change

[Previous page](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138.md?page=1)
