r-lib / credentials

Tools for Managing SSH and Git Credentials
https://docs.ropensci.org/credentials
Other
72 stars 5 forks source link

Problems with RStudio Connect installation - could we modify the `.onLoad` to fail less severely? #13

Closed slodge closed 3 years ago

slodge commented 3 years ago

Currently we have an issue where rsconnect/packrat are somehow insisting on publishing credentials as a dependency of one of our applications.

The problem with this is that credentials won't install in the restricted (sandboxed) security space that we're running RStudio Connect installation.

Example part of our application publish logs:

2021/04/20 09:14:27.234881673 Error: Command failed (1)
2021/04/20 09:14:27.234904603 
2021/04/20 09:14:27.234976523 Failed to run system command:
2021/04/20 09:14:27.234980743 
2021/04/20 09:14:27.235009739   '/opt/R/4.0.2/lib/R/bin/R' --vanilla CMD INSTALL --preclean '/opt/rstudio-connect/mnt/tmp/Rtmp5fBl45/credentials' --library='/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/4.0.2' --install-tests --no-docs --no-multiarch --no-demo 
2021/04/20 09:14:27.235035739 
2021/04/20 09:14:27.235066940 The command failed with output:
2021/04/20 09:14:27.235070376 * installing *source* package ‘credentials’ ...
2021/04/20 09:14:27.235098316 ** package ‘credentials’ successfully unpacked and MD5 sums checked
2021/04/20 09:14:27.235102006 ** using staged installation
2021/04/20 09:14:27.235128333 ** R
2021/04/20 09:14:27.235132053 ** inst
2021/04/20 09:14:27.235158977 ** byte-compile and prepare package for lazy loading
2021/04/20 09:14:27.235162227 ** help
2021/04/20 09:14:27.235188930 *** installing help indices
2021/04/20 09:14:27.235192000 ** building package indices
2021/04/20 09:14:27.235218800 ** installing vignettes
2021/04/20 09:14:27.235221890 ** testing if installed package can be loaded from temporary location
2021/04/20 09:14:27.235271267 error: could not lock config file /home/rstudio-connect/.gitconfig: Permission denied
2021/04/20 09:14:27.235275537 Error: package or namespace load failed for ‘credentials’:
2021/04/20 09:14:27.235303420  .onLoad failed in loadNamespace() for 'credentials', details:
2021/04/20 09:14:27.235306587   call: NULL
2021/04/20 09:14:27.235333547   error: Failed to call 'git config --global credential.helper cache'
2021/04/20 09:14:27.235336587 Error: loading failed
2021/04/20 09:14:27.235363554 Execution halted
2021/04/20 09:14:27.235366444 ERROR: loading failed
2021/04/20 09:14:27.235393507 * removing ‘/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/4.0.2/credentials’

I'm not entirely sure still of quite how/why credentials is being pulled into one of our applications which is being deployed into our RStudio Connect server... and I am digging into that - see some notes on https://github.com/rstudio/rsconnect/issues/505

However, I was also wondering if credentials would be interested in a PR which would allow credentials to fail with warnings rather than errors in onLoad https://github.com/r-lib/credentials/blob/17eaef8f811f0be4f2eebbfd7ac6f2c9939e9af7/R/onattach.R#L3 ?

jeroen commented 3 years ago

Sure I'll get that fixed. I'm a bit surprised that it errors, I guess it is unusual for the files in your home dir to not be writable.

jeroen commented 3 years ago

Can you test if it works now?

slodge commented 3 years ago

Wow. Thanks.

In the middle of a meeting - can check in next 6 hours

slodge commented 3 years ago

Tested using install_github

It works - such a quick turnaround - thanks 👍

slodge commented 3 years ago

Log of install was:

2021-04-20T19:14:08.2986730Z 2021/04/20 19:14:07.022863601 Installing credentials (1.3.1) ... 
2021-04-20T19:14:09.7483393Z 2021/04/20 19:14:07.493751481 curl: HTTP 200 https://codeload.github.com/r-lib/credentials/legacy.tar.gz/721bef312cc7a6fc0b77280e14b040aedd660e6c
2021-04-20T19:14:13.7984754Z 2021/04/20 19:14:11.522792387 Caching credentials.
2021-04-20T19:14:13.7985216Z 2021/04/20 19:14:11.531862557 Using cached credentials.
2021-04-20T19:14:13.7986136Z 2021/04/20 19:14:11.533879209  OK (built source)

👍