r-lib / pak

A fresh approach to package installation
https://pak.r-lib.org
646 stars 57 forks source link

Better error message if library is not writable #492

Open alexpate30 opened 1 year ago

alexpate30 commented 1 year ago

Describe the bug macos-latest (release) > Error: Process completed with exit code 1. Occurs when running R-CMD-check. Build works on windows-latest and ubuntu-latest.

Failure with run r-lib/actions/setup-r-dependencies@v2. Specific error is:

Error: ! error in pak subprocess Caused by error in verify_extracted_package(filename, pkg_cache): ! '/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//RtmpbyvQWL/filef5e36e6ed3e/bin/macosx/big-sur-x86_64/contrib/4.3/Formula_1.2-5.tgz' is not a valid R package, it is an empty archive

The package can be installed on a colleagues mac (R V4.2.3, MacOS Monterey 12.6.1.).

The culprit (Formula_1.2-5) is a dependency in Hmisc, which is a dependency in the package I am trying to install.

To Reproduce Full logs: https://github.com/alexpate30/calibmsm/actions/runs/4882576799/jobs/8712820534

Expected behavior Expecting R-CMD-check to pass as R-CMD-check is successful on my computer (windows) and my colleagues computer (MacOS).

Other Apologies is this bug report is not appropriate here. I deemed this "a bug in one of the custom R specific actions themselves", namely setup-r-dependencies, however I am new here so may have misinterpreted this language. Please close if so.

gaborcsardi commented 1 year ago

It is because your .Rprofile changes the package library directories on the builder: https://github.com/alexpate30/calibmsm/blob/master/.Rprofile

alexpate30 commented 1 year ago

Yes, I have removed and it works, thank you! May I ask, what is the logic this would cause a fail in R-CMD-check for a specific package on the MacOS system, and not a more general problem? i.e. how did you identify this so quickly?

gaborcsardi commented 1 year ago

May I ask, what is the logic this would cause a fail in R-CMD-check for a specific package on the MacOS system, and not a more general problem?

I don't know.

i.e. how did you identify this so quickly?

experience and luck I guess

I don't know if this could be considered a bug in setup-r-dependencies, but I am leaning towards no. If you change the library path (even if not entirely intentionally in your case I guess), then there isn't much we can do.

pak could probably give a better error message, though if the library is not writeable. If /Users/foo is not writeable, then this is what I get on macOS, similarly to your failed build:

❯ pak::pkg_install("cli", lib = "/Users/foo/")
✔ Updated metadata database: 4.83 MB in 7 files.
ℹ R 4.3 aarch64-apple-darwin20 packages are missing from Bioconductor
✔ Updating metadata database ... done

→ Will install 1 package.
→ The package (1.38 MB) is cached.
+ cli   3.6.1
ℹ No downloads are needed, 1 pkg (1.38 MB) is cached
Error:
! error in pak subprocess
Caused by error in `verify_extracted_package(filename, pkg_cache)`:
! '/var/folders/ph/fpcmzfd16rgbbk8mxvy9m2_h0000gn/T//RtmpuC4y6v/file5157501eb4e/bin/macosx/big-sur-arm64/contrib/4.3/cli_3.6.1.tgz' is not a valid R package, it is an empty archive
Type .Last.error to see the more details.