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

cli_alert_info() not showing in console before file.choose() #151

Closed
MarkEdmondson1234 opened this issue Apr 24, 2020 · 5 comments
Closed
Milestone

Comments

@MarkEdmondson1234
Copy link
Contributor

MarkEdmondson1234 commented Apr 24, 2020

I have this code:

cli_alert_info("Select location of your client ID file:") 
json <- file.choose()

The problem is the file.choose() launches before the message of the line above it (??) so people don't know why the window is opening :)

When the file is chosen, the message does display.

Are there any workarounds?

p.s. this happens for cat() too so is an R thing, not cli.

@gaborcsardi
Copy link
Member

It seems like a buffering issue. Try adding flush(stdout()) after the message.

@MarkEdmondson1234
Copy link
Contributor Author

That didn't do it. I have resorted to using:

cli_alert_info("Select location of your client ID file:") 
do_it <- menu(title = "Ready to download?", choices = c("Yes", "No"))
json <- file.choose()

@gaborcsardi gaborcsardi added the bug an unexpected problem or unintended behavior label Jun 10, 2020
@gaborcsardi
Copy link
Member

I experimented a bit, it seems that this is the buffering of the GUIs. In Windows RGui you can turn it off in the menu or the config, and then it is good.

I don't know if there is a way to force the printing. I also don't know if there is a way to turn off the buffering in RStudio.

For now I am closing this, will fix if we come across a way to force the output.

@gaborcsardi
Copy link
Member

gaborcsardi commented Oct 12, 2020

Ah, flush.console() seems to do it in Rgui, and also in R.app, regardless of the buffering setting.

It doesn't seem to work in RStudio, bug reported: rstudio/rstudio#8040

@gaborcsardi
Copy link
Member

I am reopening this, because we should document it, especially if they fix it in RStudio...

@gaborcsardi gaborcsardi reopened this Oct 12, 2020
@gaborcsardi gaborcsardi added documentation and removed bug an unexpected problem or unintended behavior labels Oct 12, 2020
@gaborcsardi gaborcsardi added this to the 2.4.0 milestone Mar 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants