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

Force installation from a specific repository #727

Open
wjakethompson opened this issue May 12, 2023 · 3 comments
Open

Force installation from a specific repository #727

wjakethompson opened this issue May 12, 2023 · 3 comments
Labels
blocked Blocked by an issue elsewhere feature a feature request or enhancement

Comments

@wjakethompson
Copy link

Is your feature request related to a problem? Please describe.
When a package is available in multiple repositories, it would be helpful to force installation from a specific repository. The motivating examples are the rstan and StanHeaders packages. Both are available on CRAN (rstan 2.21.8 and StanHeaders 2.21.0-7), but are not the most up to date versions. The most recent versions are in a a CRAN-like repository from the Stan group (https://github.com/stan-dev/r-packages) which has rstan 2.26.22 and StanHeaders 2.26.22. I've added the mc-stan repository to extra repositories:

- uses: r-lib/actions/setup-r@v2
  with:
    r-version: ${{ matrix.config.r }}
    rtools-version: ${{ matrix.config.rtools }}
    http-user-agent: ${{ matrix.config.http-user-agent }}
    use-public-rspm: true
    extra-repositories: https://mc-stan.org/r-packages/

However, the packages are still getting installed from the default CRAN (i.e., in the session info rstan is version 2.21.8; see example action run).

Describe the solution you'd like
Ideally, if a package exists in multiple repositories, I'd have the option to force installation from a specific repo. For example, maybe we could name extra repositories, and then use those names for install?

- uses: r-lib/actions/setup-r@v2
  with:
    r-version: ${{ matrix.config.r }}
    rtools-version: ${{ matrix.config.rtools }}
    http-user-agent: ${{ matrix.config.http-user-agent }}
    use-public-rspm: true
    extra-repositories: |
      mcstan = https://mc-stan.org/r-packages/

- uses: r-lib/actions/setup-r-dependencies@v2
  with:
    extra-packages: |
      any::rcmdcheck
      mcstan::rstan
      mcstan::StanHeaders
    needs: check

I'm not sure if that would actually work, but someway to indicate which repository a package should be installed from if multiple are available would be useful.

Describe alternatives you've considered
Currently, I'm using the url:: specification. This works, but is suboptimal because I have to track when updates are made to the stan-dev/r-packages repository, and then update the url manually.

- uses: r-lib/actions/setup-r-dependencies@v2
  with:
    extra-packages: |
      any::rcmdcheck
      url::https://mc-stan.org/r-packages/src/contrib/rstan_2.26.22.tar.gz
      url::https://mc-stan.org/r-packages/src/contrib/StanHeaders_2.26.22.tar.gz
    needs: check
@gaborcsardi
Copy link
Member

Not a 100% workaround, but if you pass upgrade: true, then pak will select the latest versions for all packages.

But yeah, I agree that this would be great, it is int the plans, and the syntax will be probably something like this:

rstan?repo=mc-stan.org

@gaborcsardi gaborcsardi added the feature a feature request or enhancement label May 12, 2023
@gaborcsardi
Copy link
Member

For the record, this needs to be implemented in pak, until that happens it is blocked.

@gaborcsardi gaborcsardi added the blocked Blocked by an issue elsewhere label May 8, 2024
@AlexAxthelm
Copy link

As a workaround for this on GH Actions, I've added an input to our org's R CMD CHECK workflow, which accepts a remotes input and appends them to DESCRIPTION before installing dependencies.

This lets us use the same action twice, one without a remotes input to target dependencies from CRAN/P3, and then again with the remotes pointing to the dev versions of our dependencies.

So, it would look something like:

r-cmd-check:
    name: R CMD Check
    uses: RMI-PACTA/actions/.github/workflows/R-CMD-check.yml@main

dev-r-cmd-check:
    name: R CMD Check (dev versions)
    uses: RMI-PACTA/actions/.github/workflows/R-CMD-check.yml@main
    with:
      upgrade-packages: 'TRUE'
      cache-version: 'dev'
      remotes: |
        RMI-PACTA/r2dii.data
        RMI-PACTA/r2dii.match

Relevant section of the workflow file:

https://github.com/RMI-PACTA/actions/blob/f1675fb6306154320285b7b004975e988dd421ff/.github/workflows/R-CMD-check.yml#L75-L92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked by an issue elsewhere feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants