You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitHub Action执行setup-r-dependencies@v2时卡住超时求助

问题描述

在GitHub Action的bookdown项目中使用r-lib/setup-r-dependencies@v2时,任务在pak创建锁文件阶段卡住,最终超时失败(耗时近6小时)。工作流已配置使用公共RSPM,但问题仍存在,情况与之前RSPM版本问题的案例类似,但当前未做特殊配置,默认应该使用最新版RSPM。

提供的工作流配置如下:

on:
  push:
    branches: [main, master]
  workflow_dispatch:

name: bookdown

jobs:
  bookdown:
    runs-on: ubuntu-latest
    # Only restrict concurrency for non-PR jobs
    concurrency:
      group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: actions/checkout@v2

      - uses: r-lib/actions/setup-pandoc@v2

      - uses: r-lib/actions/setup-r@v2
        with:
          use-public-rspm: true

      - uses: r-lib/actions/setup-r-dependencies@v2
        with:
          cache-version: 1

      - name: Cache bookdown results
        uses: actions/cache@v2
        with:
          path: _bookdown_files
          key: bookdown-${{ hashFiles('**/*Rmd') }}
          restore-keys: bookdown-

      - name: Build site
        run: bookdown::render_book("index.Rmd", quiet = TRUE)
        shell: Rscript {0}

      - name: Deploy to GitHub pages 🚀
        if: github.event_name != 'pull_request'
        uses: JamesIves/github-pages-deploy-action@4.1.4
        with:
          branch: gh-pages
          folder: _book
可能的解决方向
  • 指定pak版本:在setup-r-dependencies步骤中强制安装最新版pak,避免依赖解析的兼容性问题,配置如下:
    - uses: r-lib/actions/setup-r-dependencies@v2
      with:
        cache-version: 1
        install-pak: true
    
  • 跳过锁文件生成:如果不需要锁文件,可通过环境变量禁用这一步,在工作流的env块中添加:
    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
      PAK_LOCKFILE: "false"
    
  • 升级Action版本:将setup-r、setup-r-dependencies等Action升级到最新稳定版(比如改用@latest标签),修复已知的兼容性问题。
  • 显式指定RSPM镜像:手动指定最新RSPM镜像地址,避免默认配置的潜在问题,修改setup-r步骤:
    - uses: r-lib/actions/setup-r@v2
      with:
        use-public-rspm: true
        rspm-url: "https://packagemanager.rstudio.com/all/latest"
    
  • 重置缓存:修改cache-version的值(比如从1改为2),强制生成新的依赖缓存,避免旧缓存损坏导致的问题。
  • 本地预排查:在本地运行pak::lockfile_create(),检查是否存在依赖冲突或解析异常,提前定位问题。

内容的提问来源于stack exchange,提问作者Jake Thompson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 09:35:22