Skip to content

Set R temp directory to be in Runner temp directory #217

@cderv

Description

@cderv

On windows, short path name (or 8.3 filename) are still used on GHA. This path can cause issue with some tools - specifically we encounter error on windows with LaTeX when rendering from a tempfile()

As nothing is done specifically in setup-r, R will look at %TEMP% which contains a short filename - this has been reported already and it is normal. (actions/runner-images#712)

What about setting TEMPDIR, TMP or TEMP to the runner temp directory by default? (RUNNER_TEMP, runner.temp, process.env["RUNNER_TEMP"]). This is already use to place the R user library (R_LIBS_USER). This folder has the advantage to not have space on Windows, so no short file name with ~.

It could also be a parameter to pass to the action to set the R temp dir to a different location

      - uses: r-lib/actions/setup-r@v1
        with:
          temp_directory: ${{ runner.temp }}

Currently to make the test pass, I set this environment for the step

      - name: Check
        env:
          _R_CHECK_CRAN_INCOMING_: false
          TMPDIR: ${{ runner.temp }}
        run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
        shell: Rscript {0}

I could also do it for the job by setting globally using a custom step

      - name: change temp dir
        run: echo "TMPDIR=${{ runner.temp }}" >> $GITHUB_ENV
        shell: bash

it seems this variable can't be define in env: at the job level, as it is done with secrets (no access to ${{ runner.temp }} there it seems)

Would it be something to consider ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions