Problems using usethis with Github

After reading the new blog post on usethis v1.50, I have tried to set up my R environment as suggested. However, I have run into a few issues.

I set options in my .Rprofile as suggested in the blog post. Notable is that usethis.protocol = "ssh".

if (interactive()) {
  suppressMessages(require(devtools))
  suppressMessages(require(usethis))
  suppressMessages(require(testthat))
}

options(
  warnPartialMatchArgs = TRUE,
  warnPartialMatchDollar = TRUE,
  warnPartialMatchAttr = TRUE,
  repos = c("https://cran.rstudio.com/"),
  pillar.bold = TRUE,
  usethis.full_name = "W. Jake Thompson",
  usethis.description = list(
    `Authors@R` = 'person("W. Jake", "Thompson", email = "wjakethompson@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7339-0300"))',
    License = "GPL-3",
    Version = "0.0.0.9000"
  ),
  usethis.protocol = "ssh",
  blogdown.author = "Jake Thompson",
  blogdown.ext = ".Rmd",
  blogdown.new_bundle = TRUE,
  blogdown.method = "html",
  servr.daemon = TRUE,
  error = function() {BRRR::skrrrahh(34)}
)

After restarting R, this is my git_sitrep.

usethis::git_sitrep()
#> Git user
#> * Name: 'Jake Thompson'
#> * Email: 'wjakethompson@gmail.com'
#> * Vaccinated: TRUE
#> usethis + git2r
#> * Default usethis protocol: <unset>
#> * git2r supports SSH: FALSE
#> * Credentials: '<usethis + git2r default behaviour>'
#> GitHub
#> * Personal access token: '<found in env var>'
#> * User: 'wjakethompson'
#> * Name: 'Jake Thompson'
#> Repo
#> โ„น No active usethis project.

Created on 2019-04-10 by the reprex package (v0.2.1)

First, note that protocol being <unset> is due to the reprex not sourcing the .Rprofile. Interactively, I do see * Default usethis protocol: 'ssh'. What I can't figure out is this line:

#> * git2r supports SSH: FALSE

Indeed, when I create a new project and try to usethis::use_github(), I get the following error:

Failed to push and set tracking branch.
This often indicates a problem with git2r and the credentials.
Try this in the shell, to complete the set up:
`git push --set-upstream origin master`

Running this in the shell does succeed. Additionally, I normally use ssh for anything git related, and have never had any issues.

Any suggestions for how I can get git2r to play nicely?

Here is my session information:

devtools::session_info()
#> โ”€ Session info โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
#>  setting  value                       
#>  version  R version 3.5.2 (2018-12-20)
#>  os       macOS Mojave 10.14.4        
#>  system   x86_64, darwin15.6.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       America/Chicago             
#>  date     2019-04-10                  
#> 
#> โ”€ Packages โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
#>  package     * version date       lib source                         
#>  assertthat    0.2.1   2019-03-21 [1] CRAN (R 3.5.2)                 
#>  backports     1.1.4   2019-04-10 [1] CRAN (R 3.5.2)                 
#>  callr         3.2.0   2019-03-15 [1] CRAN (R 3.5.2)                 
#>  cli           1.1.0   2019-03-19 [1] CRAN (R 3.5.2)                 
#>  crayon        1.3.4   2017-09-16 [1] CRAN (R 3.5.0)                 
#>  desc          1.2.0   2018-05-01 [1] CRAN (R 3.5.0)                 
#>  devtools      2.0.2   2019-04-08 [1] CRAN (R 3.5.2)                 
#>  digest        0.6.18  2018-10-10 [1] CRAN (R 3.5.0)                 
#>  evaluate      0.13    2019-02-12 [1] CRAN (R 3.5.2)                 
#>  fs            1.2.7   2019-03-19 [1] CRAN (R 3.5.2)                 
#>  glue          1.3.1   2019-04-03 [1] Github (tidyverse/glue@f356a12)
#>  highr         0.8     2019-03-20 [1] CRAN (R 3.5.2)                 
#>  htmltools     0.3.6   2017-04-28 [1] CRAN (R 3.5.0)                 
#>  knitr         1.22    2019-03-08 [1] CRAN (R 3.5.2)                 
#>  magrittr      1.5     2014-11-22 [1] CRAN (R 3.5.0)                 
#>  memoise       1.1.0   2017-04-21 [1] CRAN (R 3.5.0)                 
#>  pkgbuild      1.0.3   2019-03-20 [1] CRAN (R 3.5.2)                 
#>  pkgload       1.0.2   2018-10-29 [1] CRAN (R 3.5.0)                 
#>  prettyunits   1.0.2   2015-07-13 [1] CRAN (R 3.5.0)                 
#>  processx      3.3.0   2019-03-10 [1] CRAN (R 3.5.2)                 
#>  ps            1.3.0   2018-12-21 [1] CRAN (R 3.5.0)                 
#>  R6            2.4.0   2019-02-14 [1] CRAN (R 3.5.2)                 
#>  Rcpp          1.0.1   2019-03-17 [1] CRAN (R 3.5.2)                 
#>  remotes       2.0.4   2019-04-10 [1] CRAN (R 3.5.2)                 
#>  rlang         0.3.4   2019-04-07 [1] CRAN (R 3.5.2)                 
#>  rmarkdown     1.12    2019-03-14 [1] CRAN (R 3.5.2)                 
#>  rprojroot     1.3-2   2018-01-03 [1] CRAN (R 3.5.0)                 
#>  sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 3.5.0)                 
#>  stringi       1.4.3   2019-03-12 [1] CRAN (R 3.5.2)                 
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 3.5.2)                 
#>  testthat      2.0.1   2018-10-13 [1] CRAN (R 3.5.0)                 
#>  usethis       1.5.0   2019-04-07 [1] CRAN (R 3.5.2)                 
#>  withr         2.1.2   2018-03-15 [1] CRAN (R 3.5.0)                 
#>  xfun          0.6.1   2019-04-08 [1] Github (yihui/xfun@43a56f5)    
#>  yaml          2.2.0   2018-07-25 [1] CRAN (R 3.5.0)                 
#> 
#> [1] /Users/w449t405/R
#> [2] /Library/Frameworks/R.framework/Versions/3.5/Resources/library

Created on 2019-04-10 by the reprex package (v0.2.1)

I did not realize I had not installed some homebrew packages that were needed:

$ brew install libssh2
$ brew install libgit2

After installing these, and then reinstalling the git2r package, everything is working as expected:

git2r::libgit2_features()
#> $threads
#> [1] TRUE
#> 
#> $https
#> [1] TRUE
#> 
#> $ssh
#> [1] TRUE

usethis::git_sitrep()
#> Git user
#> * Name: 'Jake Thompson'
#> * Email: 'wjakethompson@gmail.com'
#> * Vaccinated: TRUE
#> usethis + git2r
#> * Default usethis protocol: <unset>
#> * git2r supports SSH: TRUE
#> * Credentials: '<usethis + git2r default behaviour>'
#> GitHub
#> * Personal access token: '<found in env var>'
#> * User: 'wjakethompson'
#> * Name: 'Jake Thompson'
#> Repo
#> โ„น No active usethis project.

Created on 2019-04-10 by the reprex package (v0.2.1)

Unfortunately, things are still failing with usethis::use_github():

โœ” Pushing 'master' branch to GitHub and setting remote tracking branch
โ— Failed to push and set tracking branch.
  This often indicates a problem with git2r and the credentials.
  Try this in the shell, to complete the set up:
  `git push --set-upstream origin master`

Any ideas why this is failing?

1 Like

Are you able to access github succesfully using just git2r?

I know that git2r has been a tricky thing to configure in a universal way (from inside of usethis), so you might file an issue to let Jenny know.

Issue has been opened here!

I do think the issue is related to git2r rather than usethis, however. For example:

git2r::clone("git@github.com:wjakethompson/jayhawkdown.git",
             local_path = "jayhawkdown")
#> cloning into 'jayhawkdown'...
#> Error in git2r::clone("git@github.com:wjakethompson/jayhawkdown.git", : Error in 'git2r_clone': error authenticating:

Created on 2019-04-11 by the reprex package (v0.2.1)

The issue appears to be related to my password protected ssh key. For example, this works, but I'm forced to enter my password when running git2r::cred_ssh_key() even though the ssh-agent is running.

cred <- git2r::cred_ssh_key()

git2r::clone("git@github.com:wjakethompson/jayhawkdown.git",
             local_path = "jayhawkdown", credentials = cred)
#> cloning into 'jayhawkdown'...
#> Receiving objects:   1% (6/585),   36 kb
#> Receiving objects:  11% (65/585),   36 kb
#> Receiving objects:  21% (123/585),  949 kb
#> Receiving objects:  31% (182/585), 1005 kb
#> Receiving objects:  41% (240/585), 1316 kb
#> Receiving objects:  51% (299/585), 1316 kb
#> Receiving objects:  61% (357/585), 1316 kb
#> Receiving objects:  71% (416/585), 1316 kb
#> Receiving objects:  81% (474/585), 1316 kb
#> Receiving objects:  91% (533/585), 1373 kb
#> Receiving objects: 100% (585/585), 1565 kb, done.
#> Local:    master /Users/w449t405/Desktop/jayhawkdown
#> Remote:   master @ origin (git@github.com:wjakethompson/jayhawkdown.git)
#> Head:     [fa645a0] 2019-01-21: update gitignore files

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.