Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

askpass() in RStudio Rmd on Windows #3

Closed
gaborcsardi opened this issue Nov 28, 2021 · 7 comments · Fixed by #4
Closed

askpass() in RStudio Rmd on Windows #3

gaborcsardi opened this issue Nov 28, 2021 · 7 comments · Fixed by #4
Labels
bug Something isn't working

Comments

@gaborcsardi
Copy link
Member

Just returns NULL without a dialog, at least on R-devel and win 2022. It aborted my Windows 8.1 in VirtualBox, but that's probably a different issue.

Do reproduce create a new Rmd, and insert a chunk like this:

```{r}
askpass::askpass()
```

and then save it and click the Knit button.

@gaborcsardi
Copy link
Member Author

gaborcsardi commented Nov 28, 2021

Probably the same happens in Jupyter: r-lib/keyring#118

@jeroen
Copy link
Member

jeroen commented Nov 28, 2021

Hmm I don't have any win2022 here to test. I can try to setup a vm. If you want to help debug this one that would be great :)

@gaborcsardi
Copy link
Member Author

I don't think you need 2022. I think any windows will do. I can try to debug it as well.

@jeroen
Copy link
Member

jeroen commented Nov 28, 2021

OK well the fact that it returns NULL in a non-interactive environment is intended I think? We don't want it to hang a headless script or server setting.

If it aborts windows that would be very bad.

@gaborcsardi
Copy link
Member Author

gaborcsardi commented Nov 28, 2021

Right. OTOH, it would be nice to be able to override this. Some of our packages have a function like this:

cli:::is_interactive
function() {
  opt <- getOption("rlib_interactive")
  if (isTRUE(opt)) {
    TRUE
  } else if (identical(opt, FALSE)) {
    FALSE
  } else if (tolower(getOption("knitr.in.progress", "false")) == "true") {
    FALSE
  } else if (tolower(getOption("rstudio.notebook.executing", "false")) == "true") {
    FALSE
  } else if (identical(Sys.getenv("TESTTHAT"), "true")) {
    FALSE
  } else {
    interactive()
  }
}

So we could set an option if we want to force a password prompt from a non-interactive session.

@jeroen
Copy link
Member

jeroen commented Nov 28, 2021

OK yes feel free to add that.

I think there is another problem but probably unrelated to yours, that causes the credentials vignette to hang on the new win2022 CRAN machine: https://cran.r-project.org/web/checks/check_results_credentials.html

I suspect it is somehow prompting for user input when running the vignette.

@gaborcsardi
Copy link
Member Author

Yeah, so the Knitr button runs the Rmd in a non-interactive session. So this is not specific to Windows at all.

I was mislead because when running keyring::key_get() on macOS the keyring unlock dialog is handled by the OS, so works in non-interactive sessions, but on Windows keyring itself creates a dialog via askpass, and that does not work.

I'll submit a PR in a sec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants