How to use r-libs/actions with r package in a subfolder

Hi, I'm having troubles using the r-libs/actions after moving my R package files and directories in a project subfolder.

The structure of my project is:
|-package_name
| |-Dockerfile
| |-.github
| |-workflows
| |-file1.yaml
| |-file2.yaml
|-package_name
|-.Rprofile
|-DESCRIPTION
|-NAMESPACE
|-renv
| |-....
|-renv.lock
|-... other files and directories
(here you can find the entire project).

Running this workflow

name: R-CMD-check

on:
  push:
    branches: [master, main]
  pull_request:
    branches: [stable, master, main]

jobs:
  R-CMD-check:
    runs-on: ${{ matrix.config.os }}

    name: ${{ matrix.config.os }} (${{ matrix.config.r }})

    strategy:
      fail-fast: false
      matrix:
        config:
          - {os: ubuntu-latest,   r: 'release'}
          - {os: ubuntu-latest,   r: 'oldrel-1'}

    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
      R_KEEP_PKG_SOURCE: yes

    steps:
      - uses: actions/checkout@v4

      - name: Setup Pandoc
        uses: r-lib/actions/setup-pandoc@v2

      - name: Setup Latex
        uses: r-lib/actions/setup-tinytex@v2

      - name: Latex Version
        run: tlmgr --version

      - name: Install additional LaTeX packages
        run: |
          tlmgr install babel-italian
          tlmgr install microtype
          tlmgr install tex-gyre
          tlmgr install fancyhdr
          tlmgr install lastpage
          tlmgr install booktabs
          tlmgr install koma-script
          tlmgr install hyphen-italian
          tlmgr list --only-installed

      - name: Setup R
        uses: r-lib/actions/setup-r@v2
        with:
          r-version: ${{ matrix.config.r }}
          http-user-agent: ${{ matrix.config.http-user-agent }}
          use-public-rspm: true

      - name: install packages listed by renv
        uses: r-lib/actions/setup-renv@v2-branch
        with:
          working-directory: './SIconfronta'

      - name: Checking the package
        uses: r-lib/actions/check-r-package@v2
        with:
          build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
          working-directory: './SIconfronta'

results in:

Run r-lib/actions/check-r-package@v2

Run ## --------------------------------------------------------------------

Error: Error in loadNamespace(x) : there is no package called ‘rcmdcheck’

Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart

Execution halted

Error: Process completed with exit code 1.

Run ## --------------------------------------------------------------------

Show testthat output

Run actions/upload-artifact@v4

Warning: No files were found with the provided path: /home/runner/work/SIconfronta/SIconfronta/SIconfronta/check. No artifacts will be uploaded.

I've tried to install the rcmdcheck package manually with

      - name: Install rcmdcheck
        run: install.packages("rcmdcheck")
        shell: Rscript {0}

Resulting, again, in the same error.
Please, can you help me?

Thanks.

I think if you want to use rcmdcheck from within the renv project, you'll need to install it there. Or add it to the project.

Do you mean by adding rcmdcheck to the renv.lock file? Then it would also be installed during the build of the docker image, which I'd rather avoid as it is not a required library for the package itself...

Then, I don't understand why it worked when the package was in the root of the repositiory.

If you don't want to add it to the project, then you need to install it into the renv project library, on the CI. I.e. start the installation from the renv project:

      - name: Install rcmdcheck
        run: install.packages("rcmdcheck")
        shell: Rscript {0}
        working-directory: './SIconfronta'

Because then you did install it into the renv project library.

Thanks @Gabor. For now, I've added the missing packages to the project by adding them in the renv.lock file and it works: in the future I'll try the suggested solution.