Skip to content

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

Description

@MarkEdmondson1234

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.

Activity

  1. gaborcsardi commented on Apr 24, 2020

    @gaborcsardi
    Member

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

  2. MarkEdmondson1234 commented on Apr 25, 2020

    @MarkEdmondson1234
    ContributorAuthor

    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()
  3. added
    bugan unexpected problem or unintended behavior
    on Jun 10, 2020
  4. gaborcsardi commented on Oct 12, 2020

    @gaborcsardi
    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.

  5. gaborcsardi commented on Oct 12, 2020

    @gaborcsardi
    Member

    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

  6. gaborcsardi commented on Oct 12, 2020

    @gaborcsardi
    Member

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

  7. added and removed
    bugan unexpected problem or unintended behavior
    on Oct 12, 2020
  8. added this to the 2.4.0 milestone on Mar 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions