# 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:** 20\
**Page:** 1

<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, 8:44pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/1 "2020-05-08T20:44:25Z")

</div>

I have created a package using [PkgTemplates](https://github.com/invenia/PkgTemplates.jl), and everything is great. Now I want to use this package on another machine. I have copied the files. How do I add the path of the directory such that `Pkg` knows about it when I do `add MyPackage`?

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [May 8, 2020, 9:01pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/2 "2020-05-08T21:01:00Z")

</div>

You just need to supply the path to the package when you call add.

```julia
add /home/Packages/MyPackage

```

for example.

---

<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 8, 2020, 9:02pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/3 "2020-05-08T21:02:36Z")

</div>

That needs to be a git repository according to the docs.

Better to `] dev path/to/package`

Even better, OP, would be to put the package on github. Then you can add the git url and keep updated across machines.

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [May 8, 2020, 9:04pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/4 "2020-05-08T21:04:18Z")

</div>

If he used PkgTemplates it should be a git repo I believe. But yes, might as well put it on Github, even if you just make it a private repo.

---

<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, 9:18pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/5 "2020-05-08T21:18:05Z")

</div>

It does not work for me. It seems like the package is added, but after doing `using MyPackage` it cannot recognize any of the function…

---

<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 8, 2020, 9:19pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/6 "2020-05-08T21:19:08Z")

</div>

So `using MyPackage` works without error but not executing any of the functions?

---

<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, 9:20pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/7 "2020-05-08T21:20:50Z")

</div>

Exactly.

---

<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 8, 2020, 9:21pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/8 "2020-05-08T21:21:36Z")

</div>

Please post the error messages. Are you sure your `MyPackage` is `export`ing the functions? Can you call `MyPackage.foo`?

---

<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, 9:23pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/9 "2020-05-08T21:23:47Z")

</div>

Yes. On my 1st machine everything works great.  
On the other machine it doesn’t. the error message is just

```julia
julia> MyPackage.foo
ERROR: UndefVarError: foo not defined

```

---

<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 8, 2020, 9:27pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/10 "2020-05-08T21:27:45Z")

</div>

what does your `src/MyPackage.jl` code look like?

---

<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, 9:34pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/11 "2020-05-08T21:34:06Z")

</div>

```julia
module pendulum

greet() = print("Hello World!")

import Elliptic

include("pendulum_physical_functions.jl")
export I_elliptic, ω_elliptic, θ1_elliptic, θ0_elliptic, q_of_θ1_elliptic, q_of_θ0_elliptic, p_of_q, S_generating_function, E_of_λ, E_of_t, θdot_of_θ0_for_sin_squeezing, θdot_of_θ1_for_sin_squeezing

end # module

```

---

<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, 9:41pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/12 "2020-05-08T21:41:25Z")

</div>

BTW, I would upload this to git to solve the problem, but I am not sure how to do that. I tried to create a new repository on GitHub, and then to push. But I think that the `PkgTemplates` already set the remote, and therefore I can’t do it now.  
Do you know how to make it work?

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [May 8, 2020, 9:47pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/13 "2020-05-08T21:47:54Z")

</div>

I’m not sure if PkgTemplate would have set the remote or not. You can do

```julia
git remote -v

```

from the command line or a Git shell to see what your remotes are set as.

My typical workflow

- create package locally, get it partially working
- create repo on Github website. just leave it empty when you create it.
- set `origin` on my local repo to be the newly created remote repo. I use the `ssh` version because I have previously setup ssh keys. `git remote add origin git@github.com:username/reponame.git`
- `git push -u origin master` to push everything to remote (assumes you have master checked out)

---

<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, 9:51pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/14 "2020-05-08T21:51:50Z")

</div>

This is what I did. But I get get permission denied error:

```julia
Rois-MBP:pendulum roi$ git remote -v
origin	git@github.com:roiholtzman/pendulum.jl.git (fetch)
origin	git@github.com:roiholtzman/pendulum.jl.git (push)

Rois-MBP:pendulum roi$ git push -u origin master
Warning: Permanently added the RSA host key for IP address '140.82.118.3' to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

```

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [May 8, 2020, 9:54pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/15 "2020-05-08T21:54:03Z")

</div>

Then you have set the repo as private and you have not properly set up ssh access from that computer. Once you set up ssh keys with Github it should work fine.

> **[Connecting to GitHub with SSH - GitHub Docs](https://docs.github.com/en/authentication/connecting-to-github-with-ssh)**
>
> You can connect to GitHub using the Secure Shell Protocol (SSH), which provides a secure channel over an unsecured network.

---

<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, 9:57pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/16 "2020-05-08T21:57:00Z")

</div>

Thanks. I will try.

But anyway, there is not way to simply let `Pkg` know about a local package?

I do not understand what the `PkgTemplates` did so that I can simply do `add MyPackage` in the first machine. Can’t I do it in the second machine?

---

<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 8, 2020, 10:31pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/17 "2020-05-08T22:31:00Z")

</div>

My intuition is that it’s overkill to get set up on git just to fix this problem. I think there must be some step you missed in getting set up. Can you try and give an MWE (or, list your steps) for how you got set up?

---

<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:36pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/18 "2020-05-08T22:36:56Z")

</div>

I have generated my package using a template with `PkgTemplates`, and everything is working great.

On my 1st machine I have been using this packages successfully from day one.

Now, I want to use the package on my other machine (I have dropbox connecting them, so the same folder is simply on my other machine as well).

When I do `add MyPackage` on the other machine, it looks fine. things are happening:

```julia
(v1.3) pkg> add /PATH/to/pendulum
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
  Updating git-repo `/PATH/to/pendulum`
  Updating git-repo `/PATH/to/pendulum`
 Resolving package versions...
 Installed Contour ─ v0.5.3
  Updating `~/.julia/environments/v1.3/Project.toml`
 [no changes]
  Updating `~/.julia/environments/v1.3/Manifest.toml`
  [d38c429a] ↑ Contour v0.5.2 ⇒ v0.5.3

julia> using pendulum

julia> pendulum.E_of_t
ERROR: UndefVarError: E_of_t not defined

julia> E_of_t
ERROR: UndefVarError: E_of_t not defined

```

but as you can see, I can’t access the functions in the package.

---

<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 8, 2020, 10:42pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/19 "2020-05-08T22:42:24Z")

</div>

Does it work if you do `dev` instead of `add`?

---

<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:50pm UTC](https://discourse.julialang.org/t/adding-a-local-package-using-the-pkg-manager-how-to-add-the-path/39138/20 "2020-05-08T22:50:28Z")

</div>

I tried `dev` and it might help.  
I did not see any change. But then I exited julia, and started it again. Now `using MyPackage` works just fine!!!  
THANKS!

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