# Cannot add private repository from GitHub

**URL:** https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900
**Category:** New to Julia
**Tags:** github, ssh
**Created:** [July 28, 2022, 1:07am UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900 "2022-07-28T01:07:49Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Mitch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mitch/32/24224_2.png) [@Mitch](https://discourse.julialang.org/u/Mitch)
#### Post date: [July 28, 2022, 1:07am UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/1 "2022-07-28T01:07:49Z")

</div>

Hi everyone,

Unfortunately, I cannot add a private GitHub repository via Pkg.add(url=“…”), now that GitHub refuses the rsa format.  
HTTPS asks for a username and password three times then fails.  
I’ve seen the solution [HERE](https://github.com/JuliaLang/Pkg.jl/issues/3030), but I’m not sure how to implement export JULIA\_PKG\_USE\_CLI\_GIT=true and what to do next?

Any help would be greatly appreciated

---

<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: [July 28, 2022, 1:11am UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/2 "2022-07-28T01:11:32Z")

</div>

What operating system and shell are you using?

---

<div class="post-metadata">

### Author: ![cgeoga](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cgeoga/32/216186_2.png) [@cgeoga](https://discourse.julialang.org/u/cgeoga)
#### Post date: [July 28, 2022, 1:32am UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/3 "2022-07-28T01:32:03Z")

</div>

One option, which maybe isn’t officially the first recommendation, is to just clone the repo locally and do `]add /path/to/repo`.

---

<div class="post-metadata">

### Author: ![hdavid16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hdavid16/32/11531_2.png) [@hdavid16](https://discourse.julialang.org/u/hdavid16)
#### Post date: [July 28, 2022, 4:59am UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/4 "2022-07-28T04:59:13Z")

</div>

The password you need to provide is a personal access token, which you can create under the developer settings on GitHub. An alternative is to use VS Code and add the GitHub extension and sign in to it. Then it should let you add the package without authenticating.

---

<div class="post-metadata">

### Author: ![Mitch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mitch/32/24224_2.png) [@Mitch](https://discourse.julialang.org/u/Mitch)
#### Post date: [July 28, 2022, 2:32pm UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/5 "2022-07-28T14:32:44Z")

</div>

Hi everyone,

Thanks for the suggestions!

Solution: uninstall Julia 1.7.3, reinstall and BEFORE you run Julia create the startup.jl file with ENV[“JULIA\_PKG\_USE\_CLI\_GIT”]=true. Follow Github’s SSH key guide [here](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/checking-for-existing-ssh-keys), then exeucte the below:

```julia
using Pkg
Pkg.add(url="...")

```

I replicated the issue where the SSH key wasn’t working by starting Julia before creating the startup.jl file, but I’m not sure why… regardless, hopefully that helps and thanks for the suggestions everyone.

---

<div class="post-metadata">

### Author: ![Mitch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mitch/32/24224_2.png) [@Mitch](https://discourse.julialang.org/u/Mitch)
#### Post date: [July 28, 2022, 2:35pm UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/6 "2022-07-28T14:35:03Z")

</div>

Thanks for the suggestion @hdavid16, I was already signed into VScode with the GitHub extension…, but I the environment variable is working!

---

<div class="post-metadata">

### Author: ![Mitch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mitch/32/24224_2.png) [@Mitch](https://discourse.julialang.org/u/Mitch)
#### Post date: [July 28, 2022, 2:37pm UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/7 "2022-07-28T14:37:25Z")

</div>

Thanks for the suggestion @cgeoga! Are there issues with using this method and dockerizing Julia containers?

---

<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: [March 9, 2023, 11:00pm UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/8 "2023-03-09T23:00:53Z")

</div>

I have the same issue.  
Could you elaborate on how to make this access token?

(I have SSH tokens that allow me to connect from the terminal, but I cannot clone my package via `Pkg`).

---

<div class="post-metadata">

### Author: ![hdavid16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hdavid16/32/11531_2.png) [@hdavid16](https://discourse.julialang.org/u/hdavid16)
#### Post date: [March 9, 2023, 11:43pm UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/9 "2023-03-09T23:43:17Z")

</div>

> **[Managing your personal access tokens - GitHub Docs](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)**
>
> You can use a personal access token in place of a password when authenticating to GitHub in the command line or with the API.

---

<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: [March 10, 2023, 12:01am UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/10 "2023-03-10T00:01:23Z")

</div>

Thanks!

I followed the steps, but I still cannot clone my package:  
`ERROR: failed to clone from https://github.com/my_package.jl, error: GitError(Code:ERROR, Class:HTTP, unexpected http status code: 403)`

I am not sure what is the issue.

---

<div class="post-metadata">

### Author: ![hdavid16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hdavid16/32/11531_2.png) [@hdavid16](https://discourse.julialang.org/u/hdavid16)
#### Post date: [March 10, 2023, 3:52am UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/11 "2023-03-10T03:52:56Z")

</div>

The url for your package looks wrong. It should be something like `https://github.com/<YOUR USER NAME>/my_package.jl`

---

<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: [March 10, 2023, 4:06am UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/12 "2023-03-10T04:06:04Z")

</div>

Yeah, I changed the URL just for the post. I have the correct URL. Here it is in full:

```julia
pkg> add https://github.com/roiholtzman/Roi.jl
     Cloning git-repo `https://github.com/roiholtzman/Roi.jl`
Username for 'https://github.com': roiholtzman
Password for 'https://roiholtzman@github.com':
ERROR: failed to clone from https://github.com/roiholtzman/Roi.jl, error: GitError(Code:ERROR, Class:HTTP, unexpected http status code: 403)

```

---

<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: [March 10, 2023, 4:57am UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/13 "2023-03-10T04:57:20Z")

</div>

I just tried this and it works for me with version 1.8.5 on Ubuntu.

Have you tested your key by doing a simple `git clone` on the commandline (for a local user that does not have ssh access to your Github account?

---

<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: [March 10, 2023, 10:55pm UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/14 "2023-03-10T22:55:58Z")

</div>

I do have SSH set to access github. So I cannot really test this.

---

<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: [March 11, 2023, 3:23am UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/15 "2023-03-11T03:23:35Z")

</div>

You can deactivate most ssh settings by temporarily renaming ~/.ssh to something else (after testing you just rename it back to ~/.ssh). To me it sounds like the most likely cause of your problem is that your key does not work. Which operating system are you on?

---

<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: [March 11, 2023, 3:37am UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/16 "2023-03-11T03:37:00Z")

</div>

My key works fine. I know that since when I push things to my github account, I do not need to type a password.  
I am on a MacOS Ventura.

---

<div class="post-metadata">

### Author: ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)
#### Post date: [March 11, 2023, 7:40am UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/17 "2023-03-11T07:40:53Z")

</div>

I’m lost. Why are you discussing ssh keys while using an `https` URL?

---

<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: [March 11, 2023, 7:59am UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/18 "2023-03-11T07:59:51Z")

</div>

@GunnarFarneback You are right, my mistake (I thought that git would try to use ssh even on https urls, but it doesn’t).

@roi.holtzman can then simply test his personal access token by typing:

```bash
git clone https://github.com/roiholtzman/Roi.jl

```

and when git prompts for a password, then paste in the personal access token

---

<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: [March 11, 2023, 3:45pm UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/19 "2023-03-11T15:45:20Z")

</div>

I tried, but it seems I did not grant a “write” access. Why should I do that?  
And also, how?

```julia
% git clone https://github.com/roiholtzman/Roi.jl
Cloning into 'Roi.jl'...
Username for 'https://github.com': roi.holtzman@gmail.com
Password for 'https://roi.holtzman@gmail.com@github.com':
remote: Write access to repository not granted.
fatal: unable to access 'https://github.com/roiholtzman/Roi.jl/': The requested URL returned error: 403

```

---

<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: [March 11, 2023, 4:10pm UTC](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900/20 "2023-03-11T16:10:51Z")

</div>

My guess is that you should use `roiholtzman` as your username rather than `roi.holtzman@gmail.com`. My personal access token has read only access and did not have a problem.

[Next page](https://discourse.julialang.org/t/cannot-add-private-repository-from-github/84900.md?page=2)
