quarto-dev / quarto-actions

GNU General Public License v2.0
228 stars 53 forks source link

Error: C stack usage X is too close to the limit #100

Closed Unco3892 closed 8 months ago

Unco3892 commented 8 months ago

Hi,

I have a Quarto website for a course here https://github.com/do-unil/mlba which runs fine locally and when you have _freeze directory with GitHub actions. However, when removing the _freeze directory from the repo for a clean rendering with GitHub actions, I get the following error https://github.com/do-unil/mlba/actions/runs/8005417025/job/21864790141#step:7:648 . I tried modifying the .github/workflows/.publish.yml that occurs often for Quarto here https://quarto.org/docs/troubleshooting/index.html#out-of-memory-issues, setting the environment variable with export before the Quarto installation but no success.

I then thought this may be a more general R memory limit issue by looking at the solutions https://stackoverflow.com/questions/14719349/error-c-stack-usage-is-too-close-to-the-limit and https://community.rstudio.com/t/error-c-stack-usage-7974692-is-too-close-to-the-limit-with/90465, I tried also modifying the publish.yml according to that but still no success:

on:
  push:
    branches: main
  pull_request:
    branches: main
  workflow_dispatch:

name: Build Site

permissions:
  contents: write
  pages: write

jobs:
  build-website:
    runs-on: ubuntu-latest
    concurrency:
      group:  ${{ github.workflow }}
      cancel-in-progress: true
    defaults:
      run:
        shell: bash -l {0}
    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: actions/checkout@v3

      - name: Install Quarto CLI
        uses: quarto-dev/quarto-actions/setup@v2
        with:
          tinytex: true
          version: 1.4.330 # Uncommented this line

      - name: Install system dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y libcurl4-openssl-dev libglu1-mesa-dev libxml2-dev libssl-dev libv8-dev libfontconfig1-dev libfreetype6-dev cmake libmagick++-dev

      - name: Set up R
        uses: r-lib/actions/setup-r@v2
        with:
          use-public-rspm: true     

      - name: Set up renv
        uses: r-lib/actions/setup-renv@v2
        with:
          cache-version: 4

      - name: Publish Quarto Project
        uses: quarto-dev/quarto-actions/publish@v2
        env:
          R_MAX_VSIZE: 100Gb

      - name: Deploy 🚀
        if: github.event_name != 'pull_request'
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          branch: gh-pages
          folder: _site

Any idea how to resolve this and perhaps better document it? Thank you in advance for your help.

cscheid commented 8 months ago

The link you referred to is describing out-of-memory issues in Deno:

In this example, we’re setting the maximum amount of memory to be allocated by Deno to be 8GB.

You're running out of memory in R. That option won't work.

Unco3892 commented 8 months ago

Thank you for your reply. You're right that this related to Deno (TypeScript) but I'm not sure what element of this interferes the my Quarto rendering that is causing this. As mentioned, even if this is related to Deno, setting this environment variable seems to handle the issue locally on similar computers with 16Gb of memory (ubuntu-latest and windows-latest) to the ones of GitHub actions (ubuntu-latest), but when running in actions, it does not work. If it was a memory issue only caused by the code execution, it should not render locally either. I invite you to try rendering this locally on your hardware to verify.

cscheid commented 8 months ago

You're right that this related to Deno (TypeScript)

Sorry, but you misread my message. I said: "You're running out of memory in R." The option you've unsuccessfully used controls memory usage in Deno. That's not what the problem is. The problem is that you're running out of memory in R.

Unco3892 commented 8 months ago

Thank you again for your answer. Adding the following run to .github/workflows/publish.yml resolved the issue:

      - name: Increase RAM limit for R
        run: |
          ulimit -s 16384
          ulimit -a #confirm the limit increase