Cannot add private repository from GitHub

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, 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

What operating system and shell are you using?

1 Like

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

7 Likes

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.

2 Likes

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, then exeucte the below:

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.

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

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

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).

1 Like

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.

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

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

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)

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?

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

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?

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.

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

@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:

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

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

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

% 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

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.