title: R: Printing before keyring window opens
body: <p>I'm writing an API and before anything starts, I'll check if a key is set in the <code>keyring</code>. If not, the user is prompted to fill in the required user and password. However, I couldn't manage that the printing statements to appear in the console before the <code>keyring</code> window opens. Am I doing somthing wrong?</p>
  <pre><code>API &lt;- R6Class(&quot;API&quot;,
    private = list(
      m_usr = NULL,
      m_pwd = NULL
    ),
    public = list(
      initialize = function() {
        private$m_usr &lt;- tryCatch(
          {
            keyring::key_get(service = &quot;test-user&quot;, keyring = &quot;R&quot;, username = Sys.getenv(&quot;USERNAME&quot;))
          },
          error = function(...) {
            print(&quot;No usr found in keyring R. Please set it up.&quot;)
            keyring::key_set(service = &quot;test-user&quot;, keyring = &quot;R&quot;, username = Sys.getenv(&quot;USERNAME&quot;))
            return(keyring::key_get(service = &quot;test-user&quot;, keyring = &quot;R&quot;, username = Sys.getenv(&quot;USERNAME&quot;)))
          }
        )
        private$m_pwd &lt;- tryCatch(
          {
            keyring::key_get(service = &quot;test-pwd&quot;, keyring = &quot;R&quot;, username = Sys.getenv(&quot;USERNAME&quot;))
          },
          error = function(...) {
            print(&quot;No pwd found in keyring R. Please set it up.&quot;)
            keyring::key_set(service = &quot;test-pwd&quot;, keyring = &quot;R&quot;, username = Sys.getenv(&quot;USERNAME&quot;))
            return(keyring::key_get(service = &quot;test-pwd&quot;, keyring = &quot;R&quot;, username = Sys.getenv(&quot;USERNAME&quot;)))
          }
        )
      },
      print = function(...) {
        invisible(self)
      }
    )
  )
  </code></pre>