[R-package] allow use of custom R executable when building CRAN package #4754
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are several CI jobs in this project which rely on non-standard builds of
R
:LightGBM/.ci/test_r_package_valgrind.sh
Line 5 in d574fcb
LightGBM/.github/workflows/r_package.yml
Line 197 in d574fcb
Those custom builds of R also have their own libraries of installed R packages. Consider the following:
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 toR
.LightGBM/build-cran-package.sh
Line 143 in d574fcb
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 useRDsanscript -e "install.packages(...)"
to install dependencies and thenR 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
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 tobuild_r.R
I'd support it, but I don't think we should add it until we receive such a request.