r-lib / credentials

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

Add warning for macOS xcrun errors? #15

Open zkamvar opened 3 years ago

zkamvar commented 3 years ago

I don't know how it got past the defenses, but somehow loading this package on macOS that did not have developer tools set up ended up causing an error (https://github.com/zkamvar/sandpaper-docs/issues/33#issue-906158584). I confirmed that the user was using version 1.3.0:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Error: .onLoad failed in loadNamespace() for 'credentials', details:
  call: NULL
  error: Failed to call 'git help -a'
> packageVersion(“credentials”)
[1] ‘1.3.0’
> R.version
               _
platform       x86_64-apple-darwin17.0
arch           x86_64
os             darwin17.0
system         x86_64, darwin17.0
status
major          4
minor          0.2
year           2020
month          06
day            22
svn rev        78730
language       R
version.string R version 4.0.2 (2020-06-22)
nickname       Taking Off Again

From what I can tell, the reason it got to this error message is that Sys.which('git') will return /usr/bin/git, so the has_git_cmd() works, but it will error when calling credential_helper_list():

https://github.com/r-lib/credentials/blob/721bef312cc7a6fc0b77280e14b040aedd660e6c/R/onattach.R#L68

But since this is in a tryCatch block, I have no clue why exactly it would result in an error, but it is indeed being caught by loadNamespace() and treated as an error.