failing to devtools::install_github() from an enterprise github account - r

I am trying to install an R package from an enterprise github account
devtools::install_github(
repo = "<owner>/<repo>",
host = "github.<org_name>.com/api/v3/",
auth_token = <my_github_pat>
)
I get this error message
Error: Failed to install '<repo>' from GitHub: HTTP error 404. Not Found Did you spell the repo owner ('<owner>') and repo name ('<repo>') correctly? - If spelling is correct, check that you have the required permissions to access the repo.
I have the correct spellings, and I think that I must have the required permissions because it's actually my repo: I can push and pull from the repo just fine. I am doing the install_github() as a test case so colleagues can install my package, but I can't make sense of this error message.

Literally just needed to drop the last "/" in the host string and this worked. SMH
devtools::install_github(
repo = "<owner>/<repo>",
host = "github.<org_name>.com/api/v3",
auth_token = <my_github_pat>
)

Related

Failed to install 'unknown package' from GitHub

I am trying to install the ggpattern package from GitHub (https://www.rdocumentation.org/packages/ggpattern/versions/0.2.0)
I've reinstalled R, followed the all steps according to the site, also tried
remotes::install_github("coolbutuseless/ggpattern", force = TRUE)
But I still get:
Error: Failed to install 'unknown package' from GitHub:
HTTP error 401.
Bad credentials
Rate limit remaining: 19/60
Rate limit reset at: 2022-01-29 18:28:15 UTC
I'm working on R version 4.1.2 (newest according to me) on Windows.
Do you have any idea what is the issue here?
You need to check if you have a personal access token set in your environment. For example, when I have a Git project, I set a personal access token. However, I set this in the project environment, so that it isn't any issues outside of that environment.
To see if there is one assigned:
Sys.getenv("GITHUB_PAT")
If there is one set, write it down (you may need that in the future).
To remove it, so you can install the GitHub package:
Sys.unsetenv("GITHUB_PAT")

Internal error: Unexpected GitHub remote configuration: 'theirs'

I am currently working on a collaborative R-project, and after I forked the repository, I made a couple of changes and wanted to push them. However, when I tried to push it in the Rstudio, it raised the following error.
Internal error: Unexpected GitHub remote configuration: 'theirs'
To push the commits, I've used the following code :
pr_push()
Here are some context:
git remote -v
origin https://github.com/PPBDS/primer.git (fetch)
origin https://github.com/PPBDS/primer.git (push)
The code I used to fork the original repository.
library(usethis)
create_from_github("PPBDS/primer",
fork = TRUE,
destdir = "/mydest/",
protocol = "https")
The branch I've created to work on:
> pr_init(branch ='Python.v')
√ Pulling changes from 'origin/master'
√ Creating and switching to local branch 'Python.v'
I don't know how to fix this. Can anyone help me?
Your git remotes shows that the repo was cloned over https (no push allowed over https) and no fork was configured.
If I'm interpreting you correctly, the output should be:
origin git#github.com:AtillaColak/primer.git (fetch)
origin git#github.com:AtillaColak/primer.git (push)
upstream https://github.com/PPBDS/primer.git (fetch)
upstream https://github.com/PPBDS/primer.git (push)
Perhaps this will work? (Untested) (in a shell, not in R)
git remote rename origin upstream
git remote add origin git#github.com:AtillaColak/primer.git
If those commands do not work, the .git/config file should look like this:
[remote "origin"]
url = git#github.com:AtillaColak/primer.git
fetch = +refs/heads/*:refs/remotes/origin/*
[remote "upstream"]
url = https://github.com/PPBDS/primer.git
fetch = +refs/heads/*:refs/remotes/upstream/*
I don't encourage editing the .git/config file manually if you can avoid it, but this (if nothing else) may provide verification of other attempts.

Installing a package from private GitLab server on Windows

I am struggling with installing a package from a GitLab repository on a Windows computer.
I found different hints but still have problems to install my package from GitLab. First of all, I generated a public and private key with puttygen.exe. The files need to be changed afterwards, I had to remove comments and stuff so they look like my the file on my Unix system. So now, both public and private key files have just a single line.
I tried to install my package via devtools::install_git which takes very long and I get the error message
Error: Failed to install 'unknown package' from Git:
Error in 'git2r_remote_ls': Failed to authenticate SSH session: Unable to send userauth-publickey request
And with devtools::install_gitlab I get a different error message and I somehow have the feeling, the link which gets generated doesn't fit to my GitLab server.
Error: Failed to install 'unknown package' from GitLab:
cannot open URL 'https://gitlab.rlp.net/api/v4/projects/madejung%2FMQqueue.git/repository/files/DESCRIPTION/raw?ref=master'
My complete code to test at the moment is
creds <- git2r::cred_ssh_key(publickey="~/.ssh/id_rsa_gitlab.pub",
privatekey="~/.ssh/id_rsa_gitlab")
devtools::install_git(
url='git#gitlab.rlp.net:madejung/MQqueue.git',
quiet=FALSE,
credentials=creds)
devtools::install_gitlab(
repo='madejung/MQqueue.git',
host='gitlab.rlp.net',
quiet=FALSE,
credentials=creds
)
My id_rsa_gitlab.pub file looks like this and is just a single line:
ssh-rsa AAAA....fiwbw== rsa-key-20200121
The id_rsa_gitlab file has just the code:
AAABA.....3WNSIAGE=
Update
On my Mac system it works as expected after installing the libssh2 library via homebrew and and recompiling git2r with install.packages("git2r", type = "source").
So the working code on my machine is:
creds <- git2r::cred_ssh_key(publickey="~/.ssh/id_rsa_gitlab.rlp.net.pub",
privatekey="~/.ssh/id_rsa_gitlab.rlp.net")
devtools::install_git(
url='git#gitlab.rlp.net:madejung/MQqueue.git',
quiet=FALSE,
credentials=creds
)
For some strange reason, the devtools::install_git call needs about a minute to fail in the end. I have no idea where the problem here is.
After struggling for almost a day, I found a solution I can live with...
I first created a PAT (Personal Access Token) in my gitlab account and granted full API access. For some reason the read_only access didn't worked and I am now tired to figure out what the problem is.
After this I had still problems to install my package and for some reason, the wininet setting for downloading doesn't work.
I used the command capabilities("libcurl") to check if libcurl is available on my windows, which was and tried to overwrite wininet to libcurl by using method='libcurl' in the install function. Somehow, this was not enough so I overwrote the options variable download.file.method directly.
options("download.file.method"='libcurl')
devtools::install_gitlab(
repo='madejung/MQqueue',
auth_token='Ho...SOMETHING...xugzb',
host='gitlab.rlp.net',
quiet=FALSE, force=TRUE
)

R language. Private GitLab. Unable to send userauth-publickey request Error

I can successfully access gitlab project using Git Bash or via R-studio with my credentials.
But when I try to install project using devtools it returns error.
Here is my code
creds = git2r::cred_ssh_key(publickey = "C:\\Users\\user\\.ssh\\id_rsa.pub", privatekey = "C:\\Users\\user\\.ssh\\id_rsa")
devtools::install_git("git#gitlab.mycompany.com:my_project.git", credentials = creds)
Here is log:
Downloading git repo git#gitlab.mycompany.com:my_projects/my_project.git
Installation failed: Error in 'git2r_clone': Failed to authenticate SSH session: Unable to send userauth-publickey request
I use R-Studio, Windows 7.
Issue was fixed by recreation of key

Issue with R - Shiny command runGitHub() [duplicate]

I am trying to install a sample package from my github repo:
https://github.com/jpmarindiaz/samplepkg
I can install it when the repo is public using any of the following commands through the R interpreter:
install_github("jpmarindiaz/rdali")
install_github("rdali",user="jpmarindiaz")
install_github("jpmarindiaz/rdali",auth_user="jpmarindiaz")
But when the git repository is private I get an Error:
Installing github repo samplepkg/master from jpmarindiaz
Downloading samplepkg.zip from
https://github.com/jpmarindiaz/samplepkg/archive/master.zip
Error: client error: (406) Not Acceptable
I haven't figured out how the authentication works when the repo is private, any hints?
Have you tried setting a personal access token (PAT) and passing it along as the value of the auth_token argument of install_github()?
See ?install_github way down at the bottom (Package devtools version 1.5.0.99).
Create an access token in:
https://github.com/settings/tokens
Check the branch name and pass it to ref
devtools::install_github("user/repo"
,ref="main"
,auth_token = "tokenstring"
)
A more modern solution to this problem is to set your credentials in R using the usethis and credentials packages.
#set config
usethis::use_git_config(user.name = "YourName", user.email = "your#mail.com")
#Go to github page to generate token
usethis::create_github_token()
#paste your PAT into pop-up that follows...
credentials::set_github_pat()
#now remotes::install_github() will work
remotes::install_github("username/privaterepo")
More help at https://happygitwithr.com/common-remote-setups.html#common-remote-setups

Resources