Skip to content

Commit cd365e9

Browse files
authored
[R-package] [ci] Manually install 'Matrix' (fixes #6433) (#6434)
1 parent 92a8741 commit cd365e9

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

.ci/test_r_package.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,24 @@ fi
110110
# "Warning: dependency ‘lattice’ is not available"
111111
if [[ "${R_MAJOR_VERSION}" == "3" ]]; then
112112
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}')"
113+
else
114+
# {Matrix} needs {lattice}, so this needs to run before manually installing {Matrix}.
115+
# This should be unnecessary on R >=4.4.0
116+
# ref: https://github.com/microsoft/LightGBM/issues/6433
117+
Rscript --vanilla -e "install.packages('lattice', repos = '${CRAN_MIRROR}', lib = '${R_LIB_PATH}')"
113118
fi
114119

120+
# manually install {Matrix}, as {Matrix}=1.7-0 raised its R floor all the way to R 4.4.0
121+
# ref: https://github.com/microsoft/LightGBM/issues/6433
122+
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}')"
123+
115124
# Manually install Depends and Imports libraries + 'knitr', 'markdown', 'RhpcBLASctl', 'testthat'
116125
# to avoid a CI-time dependency on devtools (for devtools::install_deps())
117126
# NOTE: testthat is not required when running rchk
118127
if [[ "${TASK}" == "r-rchk" ]]; then
119-
packages="c('data.table', 'jsonlite', 'knitr', 'markdown', 'Matrix', 'R6', 'RhpcBLASctl')"
128+
packages="c('data.table', 'jsonlite', 'knitr', 'markdown', 'R6', 'RhpcBLASctl')"
120129
else
121-
packages="c('data.table', 'jsonlite', 'knitr', 'markdown', 'Matrix', 'R6', 'RhpcBLASctl', 'testthat')"
130+
packages="c('data.table', 'jsonlite', 'knitr', 'markdown', 'R6', 'RhpcBLASctl', 'testthat')"
122131
fi
123132
compile_from_source="both"
124133
if [[ $OS_NAME == "macos" ]]; then

docs/FAQ.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,22 @@ As of LightGBM v4.0.0, ``setinfo()`` has been replaced by a new method, ``set_fi
236236

237237
If you are experiencing this error when running ``lightgbm``, you may be facing the same issue reported in `#2715 <https://github.com/microsoft/LightGBM/issues/2715>`_ and later in `#2989 <https://github.com/microsoft/LightGBM/pull/2989#issuecomment-614374151>`_. 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.
238238

239+
4. package ‘Matrix’ is not available
240+
241+
In April 2024, ``Matrix==1.7-0`` was published to CRAN.
242+
That version had a floor of ``R (>=4.4.0)``.
243+
``{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.
244+
245+
.. code-block:: text
246+
247+
package ‘Matrix’ is not available for this version of R
248+
249+
To fix that without upgrading to R 4.4.0 or greater, manually install an older version of ``{Matrix}``.
250+
251+
.. code-block:: R
252+
253+
install.packages('https://cran.r-project.org/src/contrib/Archive/Matrix/Matrix_1.6-5.tar.gz', repos = NULL)
254+
239255
------
240256

241257
Python-package

0 commit comments

Comments
 (0)