Open SueYang opened 3 years ago
Can you please include the error message from keyring?
Hi I already pasted the error message in the op
No, it is not. Your code catches the error in e
and then ignores it and throws another error without an error message.
E.g.
tryCatch(
stop("original error message"),
error = function(e) {
cat("something failed"); stop()
}
)
#> something failedError in value[[3L]](cond) :
Btw. it also does not run keyring_lock("ds")
on error, if that was your intent.
Got it. I remove the trycatch part and here's the error message from keyring package:
I have this problem and it's really hurting. This works if I use getPass instead.
I could work around this issue if keyring_create allowed an optional password to be passed in. It would be more logic in my code I'm working on.
However at present this blocks me from being able to use keyring to manage api_keys for producing reports in Rmarkdown.
---
title: "test pass"
author: "Biostatistics IT Staff"
date: "11/4/2021"
output: html_document
---
\```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(getPass)
library(askpass)
\```
# getPass
\```{r getpass}
getPass()
\```
# askpass
\```{r askpass}
askpass()
\```
Also I'm using R 4.1.2. RStudio, 2021.09.0 Build 351
This will be eventually fixed in askpass: https://github.com/r-lib/askpass/issues/3
Until then you can use a workaround and query the password with getPass()
first:
keyring::keyring_unlock("ds", password = getPass::getPass())
.pwd<- key_get("db", keyring = "ds")
Hi, when using latest version (1.2.0) to knit R markdown file, there's no prompt for password.
if(!exists(".pwd")) { tryCatch({ .pwd<- key_get("db", keyring = "ds")
make sure to lock the keyring at the end
}, error = function(e) { cat("Error when unlocking ds") stop() } ) }
And the error message are
After switching back to older version keyring (1.1.0) the problem is gone.