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

[R-package] allow use of custom R executable when building CRAN package #4754

Merged
merged 2 commits into from
Oct 31, 2021

Conversation

jameslamb
Copy link
Collaborator

There are several CI jobs in this project which rely on non-standard builds of R:

Those custom builds of R also have their own libraries of installed R packages. Consider the following:

docker run \
  --rm \
  -it \
  wch1/r-debug:latest \
  /bin/bash

# confirm R and RD don't have {data.table}
# result --> Error in library(data.table) : there is no package called ‘data.table’
Rscript -e "library(data.table)"
RDscript -e "library(data.table)"

# install {data.table} for R only
Rscript -e "install.packages('data.table', repos = 'https://cran.r-project.org')"

# check again...{data.table} can be library()'d with R/Rscript, but not RD/RDscript
Rscript -e "library(data.table)"
RDscript -e "library(data.table)"

image

This project's CI jobs using custom R builds all rely on the script build-cran-package.sh to build the package. That script has its R executable hard-coded to R.

R CMD build \

Until now, this hasn't caused any issues. Since this project doesn't use vignettes, R CMD build is just lightweight code that moves files around and creates a .tar.gz with those files in it.

However, as of #3946, R CMD build will actually install {lightgbm}, so that it can build vignette outputs (as noted in #4752). Once that happens, it will be problematic to mix builds of R, e.g. to use RDsanscript -e "install.packages(...)" to install dependencies and then R CMD build to build {lightgbm}.

Noticed this when the sanitizer builds failed on #3946 . e.g. https://github.com/microsoft/LightGBM/runs/4053638309?check_suite_focus=true failed with the following error

Error in loadVignetteBuilder(pkgdir, TRUE) :
vignette builder 'knitr' not found
Execution halted

What this PR changes

This PR proposes allowing customization of the R executable used by build-cran-package.sh. It also changes existing CI jobs using custom R builds to take advantage of that feature.

Pushing similar changes to #3946 fixed the issues I mentioned above, so I'm confident this will work.

Why not also allow this customization for CMake-based builds?

I decided not to propose a similar change to build_r.R (the build script for CMake-based builds), just to avoid this PR getting larger and to avoid further complicating that already-complex script. If someone requests such a change to build_r.R I'd support it, but I don't think we should add it until we receive such a request.

@jameslamb jameslamb changed the title [R-package] allow use of custom R executable building CRAN package [R-package] allow use of custom R executable when building CRAN package Oct 30, 2021
Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, nicely done! Thank you very much for finding non-invasive solution to alter the R executable in our CI. Just one very minor suggestion.

build-cran-package.sh Show resolved Hide resolved
Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
@jameslamb jameslamb merged commit 08ccd4a into master Oct 31, 2021
@jameslamb jameslamb deleted the fix/custom-r-version branch October 31, 2021 03:31
@StrikerRUS StrikerRUS mentioned this pull request Jan 6, 2022
13 tasks
@jameslamb jameslamb mentioned this pull request Oct 7, 2022
40 tasks
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants