r-lib/keyring

keyring knit error (macOS)

obregos opened this issue · 1 comments

The following code in my .Rmd does not work as expected when running Knit.

knitr::opts_chunk$set(echo = TRUE)

library(keyring)
keyring::keyring_unlock("API_KEYs")

Running this .Rmd chunk alone prompts me for my password and returns the keyring correctly. However, when I Knit the .Rmd file it does not prompt me for a password and returns the following error:

Error in b_macos_keyring_unlock(self, private, keyring, password) : 
  Aborted unlocking keyring

R.version: 4.2.3
MacOS Version 11.6.5
keyring version 1.3.1

keyring uses askpass::askpass() to read the password. This does not work non-interactively, but you can set the askpass option as a workaround. See the askpass documentation for details.