r-universe-org / help

Support and bug tracker for R-universe
https://docs.r-universe.dev/
8 stars 2 forks source link

Missing `xclip` causes my package build to fail #425

Closed TanguyBarthelemy closed 3 weeks ago

TanguyBarthelemy commented 3 weeks ago

Hi,

I would like to build my package TBox (https://tanguybarthelemy.r-universe.dev/TBox and https://github.com/TanguyBarthelemy/TBox) with r-universe. But I got some errors when it tries to build the binaries:

image

My package relies on the R package clipr which relies on xclip or xsel for Linux distributions (see readme https://github.com/mdlincoln/clipr).

So to build with a GHA my packages I used the same configuration as clipr.

in clipr:

https://github.com/mdlincoln/clipr/blob/d14fc11f37c7ea90e1598fab9b597634f77376d9/.github/workflows/R-CMD-check.yaml#L70-L90

in TBox:

https://github.com/TanguyBarthelemy/TBox/blob/7b408d2e4fd5ee0e7521124a1251b95d6939dfe0/.github/workflows/R-CMD-check.yaml#L41-L56

In the r-universe build, I get the error:

Error: Clipboard on X11 requires 'xclip' (recommended) or 'xsel';

https://github.com/r-universe/tanguybarthelemy/actions/runs/9389973866/job/25858803484#step:4:356

So how can I configure the r-universe GHA to build my package with the needed Linux package installations?

Also my package need pandoc, rmarkdown and xelatex to build pdf output so for other OS (windows, Mac-OS), the build fails too:

https://github.com/r-universe/tanguybarthelemy/actions/runs/9389973866/job/25858805209#step:5:413 https://github.com/r-universe/tanguybarthelemy/actions/runs/9389973866/job/25858802916#step:5:400

Can I configure it too?

Thank you very much!

jeroen commented 3 weeks ago

Your package did succeed to build, but it fails to run an example in the check. But it was still published including binaries for all platforms, the check is just informative.

It is better to not assume all users and server have xelatex... I suggest you skip the example if those tools are not found. For example:

has_xelatex <- function(){
  nchar(Sys.which("xelatex")) > 0
}
TanguyBarthelemy commented 3 weeks ago

Thank you very much! Of course the built packages are in the r-universe, I thought red icon meant errors...

image

I will correct this xelatex configuration to build a pdf even if the user uses pdflatex or lualatex.

jeroen commented 3 weeks ago

Yes the red means test errors (not build errors) those are different :) I added xclip to the linux image but it did not fix that issue.

TanguyBarthelemy commented 3 weeks ago

Yes the remaining error is because you need to add an environment variable DISPLAY as here:

https://github.com/TanguyBarthelemy/TBox/blob/7b408d2e4fd5ee0e7521124a1251b95d6939dfe0/.github/workflows/R-CMD-check.yaml#L32

jeroen commented 3 weeks ago

We're running an xvbf server on :6 and have DISPLAY set but that does not seem to help.

Perhaps you need to add a check if DISPLAY is set and give an informative error if not?

What about these lines. Should you perhaps run those in your package startup ?

TanguyBarthelemy commented 3 weeks ago

Yes, you may be right. But couldn't this generate an error for users who don't have xclip and xvfb installed?

I could perhaps add a clipr::clipr_available() test to ensure that the tools are installed and generate an error (with clipr::dr_clipr()).

I'll have a look at how to set this up:

jeroen commented 3 weeks ago

I think you should let the setup of xvfb (and DISPLAY) to the user because on Linux desktop systems we use regular X and it should be working without xvfb.

So perhaps what you can do on Linux is check for the presence of the DISPLAY variable (and give a warning/error if it is not set) and also test if xclip is available. I have no idea what those other lines do, but if it is general setup may be run them in your .onLoad() function.

jeroen commented 3 weeks ago

Closing this issue now because I think there is nothing else we can do on the r-universe side of things.