抑制遥控器::install_github 消息

问题描述

我必须安装一个包 - ggpattern - 通过 github 和 remotes::install_github("coolbutuseless/ggpattern"

对于我通过 CRAN 安装/加载的所有其他软件包,我使用 suppressWarnings()suppressMessages() 禁止所有消息,但这些消息不适用于 install_github。

当我按照这个线程将 remotes:install_github 包装到 capture.output() 时:R - suppressMessages / suppressWarnings not working

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

它抑制了部分输出显示为灰色而不是红色),但仍显示整个实际安装过程中的所有消息(红色消息)。

有什么办法可以抑制这些吗?

我的脚本是交互式的,并且将由一个会被这些消息混淆的用户提供。

编辑:

我从这个链接尝试了两个 system2 版本,它们都给了我一个错误(除了非常慢;几乎以为它崩溃了 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",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"))

我收到以下错误

Error: Failed to install 'ggpattern' from GitHub:
  C stack usage  7970672 is too close to the limit

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)