【问题标题】:Bookdown Document Not Rendering Outputs CorrectlyBookdown 文档未正确呈现输出
【发布时间】:2021-02-25 14:12:00
【问题描述】:

我有一个 bookdown 文档,可以在我的本地机器上正常渲染,但是当我使用 GitHub Actions 作为自动化进程运行它时,各个代码块的输出显示全部混乱:

这是本书的 GitHub 存储库:https://github.com/ries9112/cryptocurrencyresearch-org

这里是通过 GitHub Actions 自动运行的地方:https://github.com/ries9112/cryptocurrencyresearch-org/actions

为了帮助解决问题,我创建了一个单独的存储库作为更简单的示例,但我遇到了完全相同的问题。这是更简单示例的存储库:https://github.com/ries9112/bookdown-test

我部署了那个更简单的测试的结果,你可以在这里找到它们:https://brave-leakey-37b898.netlify.app/intro.html#here-adding-new-test

文档格式在本地完全没问题,所以看起来我可能需要安装其他东西,但我目前正在安装 pandoc 和 tinytex,我不知道还有什么可能丢失。这是定义 GitHub 操作的 YAML 文件:

jobs:
  build:
    runs-on: macOS-10.15
    steps:
      - uses: actions/checkout@v2
      - uses: r-lib/actions/setup-r@v1
      - name: Install pandoc and pandoc citeproc
        run: |
          brew install pandoc
          brew install pandoc-citeproc
      - name: Install Packages
        run: |-
          Rscript -e "install.packages(c('pins','bookdown','tidyverse','DT'))"
      - name: Refresh book
        run: |-
          Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::gitbook')"

对于在这些安装步骤中可能缺少的任何内容以使其正确渲染有什么想法吗?我也在 Ubuntu 和 Windows 上尝试过,但也遇到了同样的问题。

我还尝试了 pandoc 和 tinytex 安装的这些步骤,但遇到了同样的问题:

      - uses: r-lib/actions/setup-pandoc@v1
      - uses: r-lib/actions/setup-tinytex@v1

非常感谢有关如何解决此问题的任何想法!

Also posted to RStudio Community 如果找到答案,将同时更新两者。

【问题讨论】:

    标签: r r-markdown github-actions bookdown github-actions-runners


    【解决方案1】:

    我认为您需要停用 tidyverse 使用的 crayon 包启用的着色。

    默认情况下,当您使用 setup-r 时,它会在 Github Action 上激活 https://github.com/r-lib/actions/blob/9598b8eeb6d88de7d76d580d84443542bbfdffce/setup-r/action.yml#L14-L16

    所以你需要把它改成FALSE

          - uses: r-lib/actions/setup-r@v1
            with:
              crayon.enabled: 'FALSE'
    

    在你的行动 yaml 文件中。

    您也可以在您的 bookdown 项目中将其作为一个选项停用

    options(crayon.enabled = FALSE)
    

    您必须在 Github Action 上执行此操作,因为蜡笔在 GHA 中使用时不会自动禁用。不知道为什么

    【讨论】:

    • 谢谢!您能否将答案调整为 crayon.enabled: 'FALSE' ?看起来它需要额外的引号,但之后立即完美!非常感谢!
    猜你喜欢
    • 2020-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 2018-06-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多