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

Dockerfile doesn't build when pak is enabled #1991

Open
sgvignali opened this issue Sep 23, 2024 · 6 comments
Open

Dockerfile doesn't build when pak is enabled #1991

sgvignali opened this issue Sep 23, 2024 · 6 comments

Comments

@sgvignali
Copy link

Hi, when pak is enabled, I cannot build the Docker image. It seems that pak cannot be installed for linux.

I created a repo with an example where pak is enabled in the .Rprofile file and only the ggplot2 package is used in the project.

To generate the error run the following command, it will save the logs in the build.log file:

docker build --no-cache --progress=plain -t pak_test . 2>&1 | tee build.log

The error that I get is the following:

#14 [10/11] RUN Rscript -e 'renv::restore()'
#14 sha256:59b82b1b8fa82014af75f69e2f541601965c84ba59352c11a90df73ae5100703
#14 0.552 # Bootstrapping renv 1.0.8 ---------------------------------------------------
#14 0.552 - Downloading renv ... OK
#14 3.192 - Installing renv  ... OK
#14 9.593
#14 9.893 - One or more packages recorded in the lockfile are not installed.
#14 9.893 - Use `renv::status()` for more details.
#14 11.44 renv was unable to query available packages from the following repositories:
#14 11.44 - # https://r-lib.github.io/p/pak/stable/source/linux-gnu/__linux__/jammy/x86_64/src/contrib --------
#14 11.44 error downloading 'https://r-lib.github.io/p/pak/stable/source/linux-gnu/__linux__/jammy/x86_64/src/contrib/PACKAGES.rds' [cannot open URL 'https://r-lib.github.io/p/pak/stable/source/linux-gnu/__linux__/jammy/x86_64/src/contrib/PACKAGES.rds']
#14 11.44 error downloading 'https://r-lib.github.io/p/pak/stable/source/linux-gnu/__linux__/jammy/x86_64/src/contrib/PACKAGES.gz' [cannot open URL 'https://r-lib.github.io/p/pak/stable/source/linux-gnu/__linux__/jammy/x86_64/src/contrib/PACKAGES.gz']
#14 11.44 error downloading 'https://r-lib.github.io/p/pak/stable/source/linux-gnu/__linux__/jammy/x86_64/src/contrib/PACKAGES' [cannot open URL 'https://r-lib.github.io/p/pak/stable/source/linux-gnu/__linux__/jammy/x86_64/src/contrib/PACKAGES']
#14 11.44
#14 11.44
#14 11.44 Error: package 'pak' is not available
#14 11.45 Traceback (most recent calls last):
#14 11.45 15: renv::restore()
#14 11.45 14: renv_pak_init()
#14 11.45 13: renv_pak_init_impl(stream)
#14 11.45 12: install("pak", library = library)
#14 11.45 11: renv_retrieve_impl(packages)
#14 11.45 10: handler(package, renv_retrieve_impl_one(package))
#14 11.45  9: renv_retrieve_impl_one(package)
#14 11.45  8: withCallingHandlers(renv_available_packages_latest(package),
#14 11.45         error = function(err) stopf("package '%s' is not available",
#14 11.45             package))
#14 11.45  7: renv_available_packages_latest(package)
#14 11.45  6: stopf("package '%s' is not available", package)
#14 11.45  5: stop(sprintf(fmt, ...), call. = call.)
#14 11.45  4: .handleSimpleError(function (err)
#14 11.45     {
#14 11.45         ...
#14 11.45     }, "package 'pak' is not available", base::quote(NULL))
#14 11.45  3: h(simpleError(msg, call))
#14 11.45  2: stopf("package '%s' is not available", package)
#14 11.45  1: stop(sprintf(fmt, ...), call. = call.)
#14 11.45 Execution halted
#14 ERROR: executor failed running [/bin/sh -c Rscript -e 'renv::restore()']: exit code: 1

Moreover, I noticed that pak is not recorded in the renv.lock file.

If I run locally renv::status() I get No issues found -- the project is in a consistent state.

or with renv::snapshot() I get - The lockfile is already up to date.

Should not pak be recorded in the lockfile to fix the version? (although I should probably open another issue for this).

@aftermath99
Copy link

aftermath99 commented Sep 23, 2024

Same here, we use a self hosted artifactory repo and we noticed this part of the path has been added:

linux/jammy

If I were to use your urls as an example, what was (in renv 1.0.7):

https://r-lib.github.io/p/pak/stable/source/linux-gnu/x86_64/src/contrib/PACKAGES.rds

is now (in renv 1.0.8):

https://r-lib.github.io/p/pak/stable/source/linux-gnu/__linux__/jammy/x86_64/src/contrib/PACKAGES.rds

Just to give clarification, we have a custom repo defined in our renv.lock, declared as:

  {
    "Name": "my-inhouse-artifactory",
    "URL": "http://artifactory-prod:8082/artifactory/libs-r-fred"
  },

I then declare the package dependency as:

"rFredTools": {
  "Package": "rFredTools",
  "Version": "2.0.7",
  "Source": "Repository",
  "Repository": "my-inhouse-artifactory",
  "Requirements": [
    "checkmate",
    "httr",
    "logger",
    "lubridate",
    "pryr",
    "readr",
    "rjson",
    "uuid"
  ],
  "Hash": "b12f84f30787dd77a7d13bec2921e073"
},

I now get these errors:

#16 20.21 error downloading 'http://artifactory-prod:8082/artifactory/__linux__/jammy/libs-r-fred/src/contrib/PACKAGES.rds' [error code 22]
#16 20.21 error downloading 'http://artifactory-prod:8082/artifactory/__linux__/jammy/libs-r-fred/src/contrib/PACKAGES.gz' [error code 22]
#16 20.21 error downloading 'http://artifactory-prod:8082/artifactory/__linux__/jammy/libs-r-fred/src/contrib/PACKAGES' [error code 22]

Whereas the package is at:

http://artifactory-prod:8082/artifactory/libs-r-fred/src/contrib/rFredTools_2.0.7.tar.gz

Thank you all. Renv is excellent, we just want to understand this change.

Best regards

@kevinushey
Copy link
Collaborator

Thanks for the bug report! I believe this should be fixed in renv 1.0.9, which was just submitted as a hotfix to CRAN. Can you let me know if the issue appears to be resolved in your case?

@aftermath99
Copy link

Hi Kevin,

Wow that was fast ;)

I shall test it tomorrow and let you know.

Have a good evening!
Fred

@sgvignali
Copy link
Author

Hi @kevinushey, I can confirm that in my case renv 1.0.9 solved the problem, thanks for the very quick fix!

What about pak not being recorded in the lockfile?

@kevinushey
Copy link
Collaborator

What about pak not being recorded in the lockfile?

This seems somewhat expected if you're not explicitly using pak in the project. Otherwise, renv will always try to use the latest-available version of pak when installing packages (if configured to use pak).

@sgvignali
Copy link
Author

It make sense but maybe pak shouldn't be removed with renv::clean().
If I run this command, I get:

- No stale package locks were found.
- No temporary directories were found in the project library.
The following packages are installed in the project library, 
but appear to be no longer used in your project. 
- _cache 
- pak 
These packages will be removed.
 
Do you want to proceed? [Y/n]:

kevinushey added a commit that referenced this issue Sep 27, 2024
* tweak inference of repository type

* fix up rmarkdown link

* ignore changes in mc.cores (can happen when parallel is loaded)

* update NEWS; ignore pak in clean (#1991)

* tweak check + use of parallel
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

3 participants