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

renv::restore() failing inside GitHub Action: curl Connection timed out/URL returned error #1717

Open
martin-raisely opened this issue Oct 12, 2023 · 4 comments
Labels
bug an unexpected problem or unintended behavior
Milestone

Comments

@martin-raisely
Copy link

I am trying to use renv inside a GitHub Action. renv::restore() works on my local machine and also on a GitHub codespace but when I run it inside a GitHub Action I keep getting curl errors.

Here's an example of what I see - the packages that this error occurs on seems to change each time - though it does seem to always include [email protected] and it seems to have already successfully downloaded it earlier..

[TRUNCATED]
- Downloading DT from CRAN ...                  OK [1.4 Mb in 0.99s]
[TRUNCATED]
- Downloading memoise from CRAN ...             OK [17.4 Kb in 0.48s]
- Downloading mime from CRAN ...                OK [12.3 Kb in 0.3s]
- Downloading sass from CRAN ...                	ERROR [curl: (56) Recv failure: Connection timed out]
- Downloading sass from CRAN ...                	ERROR [curl: (22) The requested URL returned error: 404]
- Downloading bslib from CRAN ...               	ERROR [curl: (22) The requested URL returned error: 404]
- Downloading rmarkdown from CRAN ...           	ERROR [curl: (22) The requested URL returned error: 404]
- Downloading htmlwidgets from CRAN ...         	ERROR [curl: (22) The requested URL returned error: 404]
- Downloading DT from CRAN ...                  	ERROR [curl: (22) The requested URL returned error: 404]
Warning: Warning: failed to find source for 'htmltools 0.5.6' in package repositories
Warning: Warning: error downloading 'http://cran.r-project.org/src/contrib/sass_0.4.7.tar.gz' [curl: (56) Recv failure: Connection timed out]
Warning: Warning: error downloading 'http://cran.r-project.org/src/contrib/Archive/sass/sass_0.4.7.tar.gz' [curl: (22) The requested URL returned error: 404]
Warning: Warning: error downloading 'http://cran.r-project.org/src/contrib/Archive/bslib/bslib_0.5.1.tar.gz' [curl: (22) The requested URL returned error: 404]
Warning: Warning: error downloading 'http://cran.r-project.org/src/contrib/Archive/rmarkdown/rmarkdown_2.25.tar.gz' [curl: (22) The requested URL returned error: 404]
Warning: Warning: error downloading 'http://cran.r-project.org/src/contrib/Archive/htmlwidgets/htmlwidgets_1.6.2.tar.gz' [curl: (22) The requested URL returned error: 404]
Warning: Warning: error downloading 'http://cran.r-project.org/src/contrib/sass_0.4.7.tar.gz' [curl: (56) Recv failure: Connection timed out]
Warning: Warning: error downloading 'http://cran.r-project.org/src/contrib/Archive/DT/DT_0.30.tar.gz' [curl: (22) The requested URL returned error: 404]
Error: Error: failed to retrieve package '[email protected]'
Execution halted
Traceback (most recent calls last):
8: renv::restore()
7: renv_restore_run_actions(project, diff, current, lockfile, rebuild)
6: retrieve(packages)
5: handler(package, renv_retrieve_impl(package))
4: renv_retrieve_impl(package)
3: renv_retrieve_repos(record)
2: stopf("failed to retrieve package '%s'", renv_record_format_remote(record))
1: stop(sprintf(fmt, ...), call. = call.)
Error: Process completed with exit code 1.

Here's my github workflow .yml

name: render-project

on:
  push:
    branches:
    - 'main'
  workflow_dispatch:

jobs:
  render_project:
    runs-on: raisely_data_actions (Ubuntu 22.04.3 LTS-R version 4.3.1)
    env:
      RENV_PATHS_ROOT: ~/.local/share/renv
    steps:
      - uses: quarto-dev/quarto-actions/setup@v2
        with:
          version: 1.3.450
      - name: Install dependencies
        run: |
          sudo apt-get install libcurl4-openssl-dev
          sudo apt-get install libsodium-dev
          sudo apt-get install libglpk-dev
          sudo apt-get install libharfbuzz-dev  libfribidi-dev libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev
      - name: Checkout repo
        uses: actions/checkout@v3
      - name: Install R
        uses: r-lib/actions/setup-r@v2
      - name: Restore packages
        uses: r-lib/actions/setup-renv@v2
      - name: Run render
        run: |
          source("driver.R")
        shell: Rscript {0}
      - uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: gh action update results

Here's my renv.lock (converted to .txt so I could upload to github) renv.lock.

I have tried including the following config settings in my .RProfile file which I'm confident is running before renv to increase the number of retries and timeout.

options(renv.config.connect.retry = 20L)
options(renv.config.connect.timeout = 60L)

Any thoughts helpful! Sorry not quite sure how to do a reprex for this.

@kevinushey
Copy link
Collaborator

Based on the reported error, it seems most likely that CRAN was inaccessible for a short period of time: I don't think there's any explicit action required here?

@martin-raisely
Copy link
Author

martin-raisely commented Oct 16, 2023

It happens every time I try and run restore::renv() inside a codespace.

Looking at other recent issues it seems like there may be a common problem with downloading packages:

Not sure if this has something to do with #1711

@kevinushey kevinushey reopened this Oct 16, 2023
@kevinushey kevinushey added the bug an unexpected problem or unintended behavior label Oct 25, 2023
@kevinushey kevinushey added this to the 1.1.0 milestone Oct 25, 2023
@martin-raisely
Copy link
Author

I think I have managed to get around/solve this issues by adding the following settings to my .Rprofile before source("renv/activate.R").

options(renv.config.connect.retry = 20L)
options(renv.config.connect.timeout = 60L)
options(renv.download.trace = TRUE)
source("renv/activate.R")

It still might be worth investigate why if a URL that should work fails we go to an Archive/ URL that won't work (there's nothing there), e.g.:

Warning: Warning: error downloading 'http://cran.r-project.org/src/contrib/sass_0.4.7.tar.gz' [curl: (56) Recv failure: Connection timed out]
Warning: Warning: error downloading 'http://cran.r-project.org/src/contrib/Archive/sass/sass_0.4.7.tar.gz' [curl: (22) The requested URL returned error: 404]

@kevinushey
Copy link
Collaborator

For what it's worth, I'd recommend using the Cloud repository, https://cloud.r-project.org -- it should be more reliable than the main CRAN server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants