From cd365e974f472ee2381819eb77717a8085cdfad4 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 30 Apr 2024 08:02:48 -0500 Subject: [PATCH] [R-package] [ci] Manually install 'Matrix' (fixes #6433) (#6434) --- .ci/test_r_package.sh | 13 +++++++++++-- docs/FAQ.rst | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.ci/test_r_package.sh b/.ci/test_r_package.sh index c1f933bfc8a..66a3ecaa663 100755 --- a/.ci/test_r_package.sh +++ b/.ci/test_r_package.sh @@ -110,15 +110,24 @@ fi # "Warning: dependency ‘lattice’ is not available" if [[ "${R_MAJOR_VERSION}" == "3" ]]; then Rscript --vanilla -e "install.packages('https://cran.r-project.org/src/contrib/Archive/lattice/lattice_0.20-41.tar.gz', repos = NULL, lib = '${R_LIB_PATH}')" +else + # {Matrix} needs {lattice}, so this needs to run before manually installing {Matrix}. + # This should be unnecessary on R >=4.4.0 + # ref: https://github.com/microsoft/LightGBM/issues/6433 + Rscript --vanilla -e "install.packages('lattice', repos = '${CRAN_MIRROR}', lib = '${R_LIB_PATH}')" fi +# manually install {Matrix}, as {Matrix}=1.7-0 raised its R floor all the way to R 4.4.0 +# ref: https://github.com/microsoft/LightGBM/issues/6433 +Rscript --vanilla -e "install.packages('https://cran.r-project.org/src/contrib/Archive/Matrix/Matrix_1.6-5.tar.gz', repos = NULL, lib = '${R_LIB_PATH}')" + # Manually install Depends and Imports libraries + 'knitr', 'markdown', 'RhpcBLASctl', 'testthat' # to avoid a CI-time dependency on devtools (for devtools::install_deps()) # NOTE: testthat is not required when running rchk if [[ "${TASK}" == "r-rchk" ]]; then - packages="c('data.table', 'jsonlite', 'knitr', 'markdown', 'Matrix', 'R6', 'RhpcBLASctl')" + packages="c('data.table', 'jsonlite', 'knitr', 'markdown', 'R6', 'RhpcBLASctl')" else - packages="c('data.table', 'jsonlite', 'knitr', 'markdown', 'Matrix', 'R6', 'RhpcBLASctl', 'testthat')" + packages="c('data.table', 'jsonlite', 'knitr', 'markdown', 'R6', 'RhpcBLASctl', 'testthat')" fi compile_from_source="both" if [[ $OS_NAME == "macos" ]]; then diff --git a/docs/FAQ.rst b/docs/FAQ.rst index 43999931ca0..8f0024b4573 100644 --- a/docs/FAQ.rst +++ b/docs/FAQ.rst @@ -236,6 +236,22 @@ As of LightGBM v4.0.0, ``setinfo()`` has been replaced by a new method, ``set_fi If you are experiencing this error when running ``lightgbm``, you may be facing the same issue reported in `#2715 `_ and later in `#2989 `_. We have seen that in some situations, using ``data.table`` 1.11.x results in this error. To get around this, you can upgrade your version of ``data.table`` to at least version 1.12.0. +4. package ‘Matrix’ is not available + +In April 2024, ``Matrix==1.7-0`` was published to CRAN. +That version had a floor of ``R (>=4.4.0)``. +``{Matrix}`` is a hard runtime dependency of ``{lightgbm}``, so on any version of R older than ``4.4.0``, running ``install.packages("lightgbm")`` results in something like the following. + +.. code-block:: text + + package ‘Matrix’ is not available for this version of R + +To fix that without upgrading to R 4.4.0 or greater, manually install an older version of ``{Matrix}``. + +.. code-block:: R + + install.packages('https://cran.r-project.org/src/contrib/Archive/Matrix/Matrix_1.6-5.tar.gz', repos = NULL) + ------ Python-package