0

I have to install one package - ggpattern - through github with remotes::install_github("coolbutuseless/ggpattern"

For all other packages I install/load through CRAN, I suppress any and all messages with suppressWarnings() and suppressMessages(), but those aren't working for install_github.

When I wrap the remotes:install_github into capture.output() following this thread: R - suppressMessages / suppressWarnings not working

invisible(capture.output(remotes::install_github("coolbutuseless/ggpattern")))

It suppressed part of the output (that was displayed in grey rather than red), but still shows all messages from the entire actual install process (red messages).

Is there any way to supress those as well?

My script is interactive and will be sourced by a user who would be confused by those messages.

Edit:

I tried the two system2 versions from this link and they both give me an error (in addition to being really slow; almost thought it crashed R)

Suppress install outputs in R

    require(remotes)

    # store a copy of system2
    assign("system2.default", base::system2, baseenv())
    
    # create a quiet version of system2
    assign("system2.quiet", function(...)system2.default(..., stdout = FALSE,
                                                         stderr = FALSE), baseenv())
    
    # overwrite system2 with the quiet version
    assignInNamespace("system2", system2.quiet, "base")
    
    suppressMessages(install_github("coolbutuseless/ggpattern"))
    
    # reset system2 to its original version
    assignInNamespace("system2", system2.default, "base")

    # store a copy of system2
    assign("system2.default", base::system2, baseenv())
    
    # create a quiet version of system2
    assign("system2.quiet", function(...)system2.default(..., stdout = FALSE,
                                                         stderr = FALSE), baseenv())
    # redefine system2 to use system2.quiet if called from "install_github"
    assignInNamespace("system2",
                      function(...) {
                        cls <- sys.calls()
                        from_install_github <- 
                          any(sapply(cls, "[[", 1) == as.name("install_github"))
                        if(from_install_github) {
                          system2.quiet(...)
                        } else {
                          system2.default(...)
                        }},
                      "base")
    
    suppressMessages(remotes::install_github("coolbutuseless/ggpattern"))

I get the following error

Error: Failed to install 'ggpattern' from GitHub:
  C stack usage  7970672 is too close to the limit
Anke
  • 527
  • 1
  • 6
  • 19
  • Do the answers here address your problem? https://stackoverflow.com/questions/12416076/suppress-install-outputs-in-r – slamballais May 14 '21 at 08:44
  • No, unfortunately those didn't work either. I edited my original post accordingly. – Anke May 14 '21 at 18:58

0 Answers0