Pkgdown: deploy_site_github() is not finding the ssh key

Created on 17 Jan 2020  Β·  13Comments  Β·  Source: r-lib/pkgdown

Hi,

I haven't been able to get pkgdown::deploy_site_github() working at https://github.com/ComunidadBioInfo/regutools as I keep getting the no deploy key found error as shown for example at https://travis-ci.com/ComunidadBioInfo/regutools/builds/144932233. Initially I started by using usethis::use_pkgdown(); usethis::use_pkgdown_travis().

Installing deploy dependencies
Successfully installed dpl-script-1.10.14
1 gem installed
dpl.2
Preparing deploy
dpl.3
Deploying application
Error: No deploy key found, please setup with `travis::use_travis_deploy()`
Execution halted
Script failed with status 1

Initially yesterday, the Travis endpoint was .org https://travis-ci.org/ComunidadBioInfo/regutools but I moved it to .com since travis::use_travis_deploy() by default wouldn't work (travis::use_travis_deploy(endpoint = '.org') did work). In any case, at .com, I deleted the keys in both Travis and GitHub as this worked for another user https://github.com/r-lib/pkgdown/issues/970: specifically at https://github.com/ComunidadBioInfo/regutools/settings/keys and https://travis-ci.com/ComunidadBioInfo/regutools/settings. I then ran travis::use_travis_deploy() and it all seems to work (I see the new keys in both Travis and GitHub)

> travis::use_travis_deploy()
β„Ή Querying Github deploy keys from repo.
β„Ή Getting environment variables for `ComunidadBioInfo/regutools` on Travis CI.
β†’ At least one key part is missing (private or public). Deleting old keys and
  adding new deploy keys for Travis CI (`.com`) for repo regutools to Travis CI
  and Github
──────────────────────────────────────────────────────────────────────────────────────────
βœ“ Added a public deploy key to GitHub for repo `regutools`.
βœ“ Added environment variable for `ComunidadBioInfo/regutools` on Travis CI.
──────────────────────────────────────────────────────────────────────────────────────────
βœ“ Added the private SSH key as a deploy key to project `regutools` on Travis CI
  as secure environment variable `TRAVIS_DEPLOY_KEY`.
βœ“ Added the public SSH key as a deploy key to project `regutools` on Github.

At pkgdown::deploy_site_github() I see that the error is triggered when !nzchar(ssh_id) is TRUE and the default ssh_id value is ssh_id = Sys.getenv("id_rsa", "") . At https://travis-ci.com/ComunidadBioInfo/regutools/builds/144932233 I do see that TRAVIS_DEPLOY_KEY is set but maybe I need to add some other environment variable on my .travis.yml file https://github.com/ComunidadBioInfo/regutools/blob/c4e30073e3e0aa0d75aa824c5904b4e1eb721360/.travis.yml. I looked at a few other .travis.yml files at github.com/ropenscilabs like circle and travis but they use other tools (tci as in tic::deploy() for https://github.com/ropenscilabs/circle/blob/master/.travis.yml) which feels like a new rabbit hole :P.

Setting environment variables from repository settings
$ export TRAVIS_DEPLOY_KEY=[secure]

If you have other ideas on what else I should try or how I can get more information for debugging this please let me know. Thank you!

Best,
Leo

R session information

> library(travis)

Attaching package: β€˜travis’

The following object is masked from β€˜package:usethis’:

    browse_travis

> library(pkgdown)

Attaching package: β€˜pkgdown’

The following object is masked from β€˜package:devtools’:

    build_site

> options(width = 120)
> sessioninfo::session_info()
─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.6.2 (2019-12-12)
 os       macOS Catalina 10.15.2      
 system   x86_64, darwin15.6.0        
 ui       RStudio                     
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       America/New_York            
 date     2020-01-17                  

─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────
 package                * version    date       lib source                              
 AnnotationDbi            1.48.0     2019-10-29 [1] Bioconductor                        
 AnnotationHub            2.18.0     2019-10-29 [1] Bioconductor                        
 assertthat               0.2.1      2019-03-21 [1] CRAN (R 3.6.0)                      
 backports                1.1.5      2019-10-02 [1] CRAN (R 3.6.0)                      
 bibtex                   0.4.2.2    2020-01-02 [1] CRAN (R 3.6.0)                      
 Biobase                  2.46.0     2019-10-29 [1] Bioconductor                        
 BiocFileCache            1.10.2     2019-11-08 [1] Bioconductor                        
 BiocGenerics             0.32.0     2019-10-29 [1] Bioconductor                        
 BiocManager              1.30.10    2019-11-16 [1] CRAN (R 3.6.1)                      
 BiocVersion              3.10.1     2019-06-06 [1] Bioconductor                        
 bit                      1.1-14     2018-05-29 [1] CRAN (R 3.6.0)                      
 bit64                    0.9-7      2017-05-08 [1] CRAN (R 3.6.0)                      
 blob                     1.2.0      2019-07-09 [1] CRAN (R 3.6.0)                      
 callr                    3.4.0      2019-12-09 [1] CRAN (R 3.6.1)                      
 cli                      2.0.1      2020-01-08 [1] CRAN (R 3.6.0)                      
 colorout               * 1.2-1      2019-05-07 [1] Github (jalvesaq/colorout@7ea9440)  
 crayon                   1.3.4      2017-09-16 [1] CRAN (R 3.6.0)                      
 curl                     4.3        2019-12-02 [1] CRAN (R 3.6.0)                      
 DBI                      1.1.0      2019-12-15 [1] CRAN (R 3.6.0)                      
 dbplyr                   1.4.2      2019-06-17 [1] CRAN (R 3.6.0)                      
 desc                     1.2.0      2018-05-01 [1] CRAN (R 3.6.0)                      
 devtools               * 2.2.1      2019-09-24 [1] CRAN (R 3.6.1)                      
 digest                   0.6.23     2019-11-23 [1] CRAN (R 3.6.0)                      
 dplyr                    0.8.3      2019-07-04 [1] CRAN (R 3.6.0)                      
 ellipsis                 0.3.0      2019-09-20 [1] CRAN (R 3.6.0)                      
 fansi                    0.4.1      2020-01-08 [1] CRAN (R 3.6.0)                      
 fastmap                  1.0.1      2019-10-08 [1] CRAN (R 3.6.0)                      
 fs                       1.3.1      2019-05-06 [1] CRAN (R 3.6.0)                      
 glue                     1.3.1      2019-03-12 [1] CRAN (R 3.6.0)                      
 htmltools                0.4.0      2019-10-04 [1] CRAN (R 3.6.0)                      
 httpuv                   1.5.2      2019-09-11 [1] CRAN (R 3.6.0)                      
 httr                     1.4.1      2019-08-05 [1] CRAN (R 3.6.0)                      
 interactiveDisplayBase   1.24.0     2019-10-29 [1] Bioconductor                        
 IRanges                  2.20.1     2019-11-20 [1] Bioconductor                        
 jsonlite                 1.6        2018-12-07 [1] CRAN (R 3.6.0)                      
 later                    1.0.0      2019-10-04 [1] CRAN (R 3.6.0)                      
 lubridate                1.7.4      2018-04-11 [1] CRAN (R 3.6.0)                      
 magrittr                 1.5        2014-11-22 [1] CRAN (R 3.6.0)                      
 MASS                     7.3-51.5   2019-12-20 [1] CRAN (R 3.6.0)                      
 memoise                  1.1.0      2017-04-21 [1] CRAN (R 3.6.0)                      
 mime                     0.8        2019-12-19 [1] CRAN (R 3.6.0)                      
 packrat                  0.5.0      2018-11-14 [1] CRAN (R 3.6.0)                      
 pillar                   1.4.3      2019-12-20 [1] CRAN (R 3.6.0)                      
 pkgbuild                 1.0.6      2019-10-09 [1] CRAN (R 3.6.0)                      
 pkgconfig                2.0.3      2019-09-22 [1] CRAN (R 3.6.1)                      
 pkgdown                * 1.4.1      2019-09-15 [1] CRAN (R 3.6.0)                      
 pkgload                  1.0.2      2018-10-29 [1] CRAN (R 3.6.0)                      
 plyr                     1.8.5      2019-12-10 [1] CRAN (R 3.6.0)                      
 prettyunits              1.1.0      2020-01-09 [1] CRAN (R 3.6.2)                      
 processx                 3.4.1      2019-07-18 [1] CRAN (R 3.6.0)                      
 promises                 1.1.0      2019-10-04 [1] CRAN (R 3.6.0)                      
 ps                       1.3.0      2018-12-21 [1] CRAN (R 3.6.0)                      
 purrr                    0.3.3      2019-10-18 [1] CRAN (R 3.6.0)                      
 R6                       2.4.1      2019-11-12 [1] CRAN (R 3.6.1)                      
 rappdirs                 0.3.1      2016-03-28 [1] CRAN (R 3.6.0)                      
 Rcpp                     1.0.3      2019-11-08 [1] CRAN (R 3.6.0)                      
 RefManageR               1.2.12     2019-04-03 [1] CRAN (R 3.6.0)                      
 remotes                  2.1.0      2019-06-24 [1] CRAN (R 3.6.0)                      
 rlang                    0.4.2      2019-11-23 [1] CRAN (R 3.6.0)                      
 rprojroot                1.3-2      2018-01-03 [1] CRAN (R 3.6.0)                      
 RSQLite                  2.2.0      2020-01-07 [1] CRAN (R 3.6.0)                      
 rstudioapi               0.10       2019-03-19 [1] CRAN (R 3.6.0)                      
 S4Vectors                0.24.1     2019-12-01 [1] Bioconductor                        
 sessioninfo              1.1.1      2018-11-05 [1] CRAN (R 3.6.0)                      
 shiny                    1.4.0      2019-10-10 [1] CRAN (R 3.6.0)                      
 stringi                  1.4.3      2019-03-12 [1] CRAN (R 3.6.0)                      
 stringr                  1.4.0      2019-02-10 [1] CRAN (R 3.6.0)                      
 testthat               * 2.3.1      2019-12-01 [1] CRAN (R 3.6.0)                      
 tibble                   2.1.3      2019-06-06 [1] CRAN (R 3.6.0)                      
 tidyselect               0.2.5      2018-10-11 [1] CRAN (R 3.6.0)                      
 travis                 * 0.3.0.9002 2020-01-17 [1] Github (ropenscilabs/travis@3f4e59d)
 usethis                * 1.5.1      2019-07-04 [1] CRAN (R 3.6.0)                      
 vctrs                    0.2.1      2019-12-17 [1] CRAN (R 3.6.0)                      
 withr                    2.1.2      2018-03-15 [1] CRAN (R 3.6.0)                      
 xml2                     1.2.2      2019-08-09 [1] CRAN (R 3.6.0)                      
 xtable                   1.8-4      2019-04-21 [1] CRAN (R 3.6.0)                      
 yaml                     2.2.0      2018-07-25 [1] CRAN (R 3.6.0)                      
 zeallot                  0.1.0      2018-01-28 [1] CRAN (R 3.6.0)                      

[1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library

Most helpful comment

It seems https://github.com/ropenscilabs/travis/pull/129 changed the travis package to add the deploy key to the TRAVIS_DEPLOY_KEY environment variable. previously the key was added to the id_rsa environment variable, which is what pkgdown::deploy_site_github() is looking for.

We could I guess change pkgdown to look for both locations I guess...

All 13 comments

@lcolladotor I've just run into the issue and am stuck in the sample place (sshkeys configured and correctly set but build fail). My workaround is to pass TRAVIS_DEPLOY_KEY directly to the deploy_site_github function in your config file as shown below:

deploy:
  provider: script
  script: Rscript -e 'pkgdown::deploy_site_github(ssh_id = Sys.getenv("TRAVIS_DEPLOY_KEY", ""))'
  skip_cleanup: true

Thanks @zachcp! Your solution worked ^^.

Thanks for the workaround, but should this really count as closing the issue? I have the same issue using github/travis and this seems to be the most common use case and should imho be fixed in pkgdown (maybe by looking for the ssh key in several locations by default?).

At least this solution should be documented in ?pkgdown::deploy_site_github and usethis::use_pkgdown_travis IMHO.

I submitted https://github.com/r-lib/pkgdown/pull/1217 to expand the current documentation. I opted for this instead of changing the default argument values since (a) the default might work for others and (b) the SSH key name might change in the future (maybe it changed elsewhere and we are the first seeing this issue).

I finally found this thread after posting on the Travis community site

Thanks for both the workaround and the PR!

@jimhester would you mind taking a little time to figure out what's going on here?

It seems https://github.com/ropenscilabs/travis/pull/129 changed the travis package to add the deploy key to the TRAVIS_DEPLOY_KEY environment variable. previously the key was added to the id_rsa environment variable, which is what pkgdown::deploy_site_github() is looking for.

We could I guess change pkgdown to look for both locations I guess...

Thanks for finding the root of this Jim!

In my PR I recommended updating the docs, but I guess that if you have the pkgdown function search for both options that would work too (until someone changes the default name in ropenscilabs/travis again :P

There is already backward comp for the old id_rsa default if it exists.

All users starting fresh right now will not get the id_rsa env var unless they use use_travis_deploy(key_name_private = "id_rsa").

As for a solution, you could either check for both locations or change

https://github.com/r-lib/pkgdown/blob/48e12e0fc836ec8ca423b44656b97f719cd856c7/R/deploy-site.R#L81-L81

to suggest

stop("No deploy key found, please setup with travis::use_travis_deploy(key_name_private = "id_rsa"), call. = FALSE)

Also I don't think #1217 is a good workaround for this problem.


Sorry for the trouble. We were not aware that this change might cause issues here.
One of the problems if a package is not (yet) on CRAN.

We now recommend using the github actions workflow instead; which avoids all this configuration pain.

Late to the party, I'm trying to figure out what the new GH-action process is. Is there a good reference for how to use the github action workflow (especially helpful would be a reference for people who are comfortable with the "old fashioned" travis workflow).

@ldecicco-USGS I recommend using the usethis helper use_tidy_github_actions(). It should setup everything you need.

Brilliant! That's all I need! I wish I would have asked much...much...sooner :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nschiett picture nschiett  Β·  6Comments

Fazendaaa picture Fazendaaa  Β·  9Comments

privefl picture privefl  Β·  3Comments

ycphs picture ycphs  Β·  6Comments

thierrygosselin picture thierrygosselin  Β·  9Comments