Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup-r-dependencies - Why not leverage de repo options ? It fails if we want to use this action in a Github Enterprise with our own repository mirroring #918

Open
marandet opened this issue Sep 5, 2024 · 1 comment

Comments

@marandet
Copy link

marandet commented Sep 5, 2024

Describe the bug

I am using these actions in a on-premise Github Enterprise installation.
We are using our own package-manager that is configured to mirror several kind of repositories (from Docker artefacts and OS-Distributions to languages-specific libraries, including CRAN).
The point is that all of this is within our internal network so that we do not allow our github runner to have access to the internet.

I successfully run the setup-r action, leveraging the RSPM environment variable and the extra-repositories option in order to point to our Artifactory.
I also add a step in order to write the options.repos value within the Rprofile configuration file.

But the installation of the pak package still fails.

A clear and concise description of what the bug is.

To Reproduce

Here is an example of my use-case :

      - uses: r-lib/actions/setup-r@v2
        env:
          RENV_CONFIG_REPOS_OVERRIDE: https://artifactory-URL/ubuntu/dists/jammy/
          RSPM: https://artifactory-URL/ubuntu/dists/jammy/
        with:
          r-version: 'release'
          http-user-agent: 'release'
          use-public-rspm: false
          extra-repositories: 'https://artifactory-URL/R-all https://artifactory-URL/remote-cran'

      - name: Set Artifactory repo
        run: |
          cat("\noptions(repos = c(CRAN = 'https://artifactory-URL/remote-cran'), download.file.method = 'libcurl')\n", file = "~/.Rprofile", append = TRUE)
        shell: Rscript {0}

      - uses: r-lib/actions/setup-r-dependencies@v2
        env:
          RENV_CONFIG_REPOS_OVERRIDE: https://artifactory-URL/ubuntu/dists/jammy/
          RSPM: https://artifactory-URL/ubuntu/dists/jammy/
        with:
          extra-packages: any::rcmdcheck
          needs: check

And the following error occurs in the Run r-lib/actions/setup-r-dependencies@v2 step, in the Run # Install pak substep.

Run # Install pak
  # Install pak
  echo "::group::Install pak"
  if which sudo >/dev/null; then SUDO="sudo -E --preserve-env=PATH env"; else SUDO=""; fi
  $SUDO R -q -e 'dir.create(Sys.getenv("R_LIB_FOR_PAK"), recursive = TRUE, showWarnings = FALSE)'
  $SUDO R -q -e 'install.packages("pak", lib = Sys.getenv("R_LIB_FOR_PAK"), repos = sprintf("https://r-lib.github.io/p/pak/%s/%s/%s/%s", "stable", .Platform$pkgType, R.Version()$os, R.Version()$arch))'
  echo "::endgroup::"
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    GITHUB_PAT: ***
    R_KEEP_PKG_SOURCE: yes
    R_LIBS_USER: /home/runner/_work/_temp/Library
    TZ: UTC
    _R_CHECK_SYSTEM_CLOCK_: FALSE
    NOT_CRAN: true
    RSPM: https://artifactory-URL/ubuntu/dists/jammy/
    RENV_CONFIG_REPOS_OVERRIDE: https://artifactory-URL/ubuntu/dists/jammy/
    R_LIB_FOR_PAK: /opt/R/4.4.1/lib/R/site-library
Install pak
  > dir.create(Sys.getenv("R_LIB_FOR_PAK"), recursive = TRUE, showWarnings = FALSE)
  > 
  > 
  > install.packages("pak", lib = Sys.getenv("R_LIB_FOR_PAK"), repos = sprintf("https://r-lib.github.io/p/pak/%s/%s/%s/%s", "stable", .Platform$pkgType, R.Version()$os, R.Version()$arch))
  Warning: Warning: unable to access index for repository https://r-lib.github.io/p/pak/stable/source/linux-gnu/x86_[64](https://github-on-prem-URL/MyORG/MyREPO/actions/runs/7782/job/13135#step:6:67)/src/contrib:
    cannot open URL 'https://r-lib.github.io/p/pak/stable/source/linux-gnu/x86_64/src/contrib/PACKAGES'
  Warning message:
  package 'pak' is not available for this version of R
  
  A version of this package for your version of R might be available elsewhere,
  see the ideas at
  https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages 
  > 
  >

Expected behavior

The installation of every package should leverage the options.repos configuration.

Additional context

I guess that the problem is in this specific line of code

$SUDO R -q -e 'install.packages("pak", lib = Sys.getenv("R_LIB_FOR_PAK"), repos = sprintf("https://r-lib.github.io/p/pak/%s/%s/%s/%s", "${{ inputs.pak-version }}", .Platform$pkgType, R.Version()$os, R.Version()$arch))'

@marandet marandet added the bug an unexpected problem or unintended behavior label Sep 5, 2024
@gaborcsardi
Copy link
Member

This is not a bug, it is a requirement. setup-r-dependencies requires access to GitHub Pages currently.

A workaround is to do these before using setup-r-dependencies:

  • set the R_LIB_FOR_PAK environment variable to point to a package library
  • manually install pak there
  • set pak-version: none for setup-r-dependencies.

It is best to install pak into a different library than the one you use for your regular packages, in case some of those also required pak and need a different version.

@gaborcsardi gaborcsardi removed the bug an unexpected problem or unintended behavior label Sep 5, 2024
gaborcsardi added a commit that referenced this issue Sep 5, 2024
'repo' is a better option for environments like in #918.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants