r-lib / pak

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

install error for R packages with SystemRequirements (macOS) #629

Closed jhk0530 closed 6 months ago

jhk0530 commented 6 months ago

Hi, pak contributors. I really like just simple pak::pak and really appreciate on this.

However, recently I found some installing issue (may be bug) with pak

The package gdtools.

This can be installed with install.packages (from CRAN) but it can't with pak::pak and remotes::install_github

and below is log of that.

> pak::pak('davidgohel/gdtools')

β†’ Will install 1 package.
β†’ The package (0 B) is cached.
+ gdtools   0.3.7 πŸ‘·πŸΏβ€β™‚οΈπŸ”§ (GitHub: 5b54f99)
β„Ή No downloads are needed, 1 pkg is cached
β„Ή Building gdtools 0.3.7
βœ– Failed to build gdtools 0.3.7 (754ms)                            
Error:                                                             
! error in pak subprocess
Caused by error in `stop_task_build(state, worker)`:
! Failed to build source package gdtools.
Type .Last.error to see the more details.
> .Last.error
<callr_error/rlib_error_3_0/rlib_error/error>
Error: 
! error in pak subprocess
Caused by error in `stop_task_build(state, worker)`:
! Failed to build source package gdtools.
---
Backtrace:
1. pak::pak("davidgohel/gdtools")
2. pak::pkg_install(pkg, ...)
3. pak:::remote(function(...) get("pkg_install_do_plan", asNamespace("pak"))(...), …
4. err$throw(res$error)
---
Subprocess backtrace:
 1. base::withCallingHandlers(cli_message = function(msg) { …
 2. get("pkg_install_do_plan", asNamespace("pak"))(...)
 3. proposal$install()
 4. pkgdepends::install_package_plan(plan, lib = private$library, num_workers = nw, …
 5. base::withCallingHandlers({ …
 6. pkgdepends:::handle_events(state, events)
 7. pkgdepends:::handle_event(state, i)
 8. pkgdepends:::stop_task(state, worker)
 9. pkgdepends:::stop_task_build(state, worker)
10. base::throw(pkg_error("Failed to build source package {.pkg {pkg}}.", …
11. | base::signalCondition(cond)
12. global (function (e) …

and this is not necessary but I think this can be clue to solve this problem. Here's remotes::install_github's log

> remotes::install_github('davidgohel/gdtools')
Using GitHub PAT from the git credential store.
Downloading GitHub repo davidgohel/gdtools@HEAD
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?

1: All                                         
2: CRAN packages only                          
3: None                                        
4: curl (3609be2b2... -> d9f2a6f50...) [GitHub]

Enter one or more numbers, or an empty line to skip updates: 3
── R CMD build ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
βœ”  checking for file β€˜/private/var/folders/xs/53yprhh96l72pgw833r4thv40000gn/T/Rtmp75fGgy/remotes420f5517bc20/davidgohel-gdtools-5b54f99/DESCRIPTION’ ...
─  preparing β€˜gdtools’:
βœ”  checking DESCRIPTION meta-information
─  cleaning src
─  running β€˜cleanup’
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  looking to see if a β€˜data/datalist’ file should be added
─  building β€˜gdtools_0.3.7.tar.gz’

* installing *source* package β€˜gdtools’ ...
** using staged installation
Homebrew 4.2.12
Using PKG_CFLAGS=-I/opt/homebrew/include/cairo -I/opt/homebrew/include/fontconfig -I/opt/homebrew/include/freetype2
Using PKG_LIBS=-L/opt/homebrew/lib -lcairo -lfreetype
-----------------------------[ ANTICONF ]-------------------------------
Configuration failed to find libraries. Try installing:
 * deb: libcairo2-dev (Debian, Ubuntu)
 * rpm: cairo-devel (Fedora, CentOS, RHEL)
 * csw: libcairo_dev (Solaris)
 * brew: cairo (OSX)
If --static cairo freetype2 are already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a --static cairo freetype2.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
---------------------------[ ERROR MESSAGE ]----------------------------
src/tests/sysdeps.c:1:10: fatal error: 'cairo-ft.h' file not found
#include <cairo-ft.h>
         ^~~~~~~~~~~~
1 error generated.
------------------------------------------------------------------------
ERROR: configuration failed for package β€˜gdtools’
* removing β€˜/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/gdtools’
Warning message:
In i.p(...) :
  installation of package β€˜/var/folders/xs/53yprhh96l72pgw833r4thv40000gn/T//Rtmp75fGgy/file420f9400485/gdtools_0.3.7.tar.gz’ had non-zero exit status

So this shows me to there is error with cairo something.

and it is one of SystemRequirements of gdtools package.

so I think, if I install manually cairo (like brew cairo). this may be solved as SystemRequirements mentioned (I'm curious then why CRAN version installed without error)

However, in github action, I can't install it manually which generates error

How can I solve this problem? or Why pak and CRAN 's result are different?

Thanks !

gaborcsardi commented 6 months ago

How can I solve this problem?

You mean on GHA? I think you need to install XQuartz, but for that you need to modify the R-hub workflow to add this:

- if: runner.os == 'macOS'
  run: brew install --cask xquartz

I'll add this to the R-hub actions: https://github.com/r-hub/rhub/issues/606 and then you can leave rhub.yaml untouched.

Why pak and CRAN 's result are different?

Impossible to know for sure without seeing what you are running and what the output is, but my guess is that from CRAN you are installing a binary package, which does not need Cairo, because it already has it embedded.

The difference is not install.packages() vs. pak, but installing a binary package vs. a source package. I.e. install.packages("gdtools", type = "source") will also fail, and pak::pkg_install("gdtools") will succeed, I think.

jhk0530 commented 6 months ago

As you said, using that code I can check avoided or confirmed the error.

I'll wait until r-hub GHA updated !

Thanks !!