Repository: dmlc/xgboost
Pull request #11365: Enable r-universe build.
Author: login: trivialfis
Created: 2025-03-26T14:29:37Z | Merged: 2025-03-26T19:28:38Z

- Add bootstrap script according to https://docs.r-universe.dev/publish/troubleshoot-build.html#what-if-the-git-repository-is-not-a-ready-to-build-source-package
- Remove duplicated license file.
- I installed the R-universe github app on the `dmlc.r-universe.dev` repo (only this one).

I'm targeting the 3.0 branch for this PR. Once ready, I will forward the changes to the master branch.

Package index: https://dmlc.r-universe.dev/builds

related:
https://github.com/dmlc/dmlc.r-universe.dev
https://github.com/r-universe/dmlc
https://github.com/dmlc/xgboost/issues/11286#issuecomment-2751309684

For some reason, the r-universe bot took my account as the official one long ago: https://trivialfis.r-universe.dev/builds. I will [ask](https://github.com/r-universe-org/help/discussions/580) the maintainer to remove my GitHub account once the dmlc setup is finished.

Test:
``` R
install.packages('xgboost', repos = c('https://dmlc.r-universe.dev', 'https://cloud.r-project.org'))
```

Close https://github.com/dmlc/xgboost/issues/11360 .


Diff:
diff --git a/R-package/LICENSE b/R-package/LICENSE
deleted file mode 100644
index bc1c21d59fe5..000000000000
--- a/R-package/LICENSE
+++ /dev/null
@@ -1,13 +0,0 @@
-Copyright (c) 2014-2023, Tianqi Chen and XBGoost Contributors
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/R-package/bootstrap.R b/R-package/bootstrap.R
new file mode 100644
index 000000000000..dfafca67085f
--- /dev/null
+++ b/R-package/bootstrap.R
@@ -0,0 +1,36 @@
+## Script used to bootstrap R-universe build.
+
+## Execute git commands to initialize git submodules
+system("git submodule init")
+system("git submodule update")
+
+## core
+file.copy("../src", "./src/", recursive = TRUE)
+file.copy("../include", "./src/", recursive = TRUE)
+file.copy("../amalgamation", "./src/", recursive = TRUE)
+
+## dmlc-core
+dir.create("./src/dmlc-core")
+file.copy("../dmlc-core/include", "./src/dmlc-core/", recursive = TRUE)
+file.copy("../dmlc-core/src", "./src/dmlc-core/", recursive = TRUE)
+
+pkgroot <- function(path) {
+  ## read the file from path, replace the PKGROOT=../../ with PKGROOT=.
+  lines <- readLines(path)
+  lines <- gsub("PKGROOT=../../", "PKGROOT=.", lines, fixed = TRUE)
+  writeLines(lines, path)
+}
+
+## makefile and license
+file.copy("../LICENSE", "./LICENSE")
+pkgroot("./src/Makevars.in")
+pkgroot("./src/Makevars.win.in")
+
+## misc
+path <- file.path("remove_warning_suppression_pragma.sh")
+file.remove(path)
+path <- file.path("CMakeLists.txt")
+file.remove(path)
+
+## remove the directory recursively ./tests/helper_scripts
+unlink("tests/helper_scripts", recursive = TRUE)
diff --git a/doc/R-package/index.rst b/doc/R-package/index.rst
index 30b6f83e5232..56e2db4591b6 100644
--- a/doc/R-package/index.rst
+++ b/doc/R-package/index.rst
@@ -17,9 +17,16 @@ You have found the XGBoost R Package!
 Get Started
 ***********
 
-* Checkout the :doc:`Installation Guide </install>` contains instructions to install xgboost, and :doc:`Tutorials </tutorials/index>` for examples on how to use XGBoost for various tasks.
-* Read the latest `API documentation <../r_docs/R-package/docs/reference/index.html>`__ . This might refer to a newer version than the one on CRAN.
-* Read the `CRAN documentation <https://cran.r-project.org/web/packages/xgboost/xgboost.pdf>`_.
+Since XGBoost 3.0.0, the latest R package is available on
+`https://dmlc.r-universe.dev/builds <R-universe>`__ while the one on CRAN is kept at an
+older version. We will work on helping the CRAN version to catch up in the future. In the
+meantime, please use R-universe packages.
+
+* Check out the :doc:`Installation Guide </install>` for instructions on how to install
+  xgboost, and :doc:`Tutorials </tutorials/index>` for examples on how to use XGBoost for
+  various tasks.
+* Read the latest `API documentation <../r_docs/R-package/docs/reference/index.html>`__.
+* Read the `CRAN documentation <https://cran.r-project.org/web/packages/xgboost/xgboost.pdf>`_. (outdated)
 
 *********
 Vignettes
diff --git a/doc/install.rst b/doc/install.rst
index 9a7330c8b428..527ec061bf15 100644
--- a/doc/install.rst
+++ b/doc/install.rst
@@ -127,22 +127,22 @@ Visit the `Miniconda website <https://docs.conda.io/en/latest/miniconda.html>`_
 R
 -
 
-* From CRAN:
+* From R Universe
 
-  .. code-block:: R
+.. code-block:: R
 
-    install.packages("xgboost")
+    install.packages('xgboost', repos = c('https://dmlc.r-universe.dev', 'https://cloud.r-project.org'))
 
-  .. note:: Using all CPU cores (threads) on Mac OSX
+.. note:: Using all CPU cores (threads) on Mac OSX
 
-     If you are using Mac OSX, you should first install OpenMP library (``libomp``) by running
+   If you are using Mac OSX, you should first install OpenMP library (``libomp``) by running
 
-     .. code-block:: bash
+   .. code-block:: bash
 
         brew install libomp
 
-     and then run ``install.packages("xgboost")``. Without OpenMP, XGBoost will only use a
-     single CPU core, leading to suboptimal training speed.
+   and then run ``install.packages("xgboost")``. Without OpenMP, XGBoost will only use a
+   single CPU core, leading to suboptimal training speed.
 
 * We also provide **experimental** pre-built binary with GPU support. With this binary,
   you will be able to use the GPU algorithm without building XGBoost from the source.
@@ -158,6 +158,30 @@ R
     # Install XGBoost
     R CMD INSTALL ./xgboost_r_gpu_linux.tar.gz
 
+
+* From CRAN (outdated):
+
+.. warning::
+
+    We are working on bringing the CRAN version of XGBoost up-to-date, in the meantime,
+    please use packages from the R-universe.
+
+
+.. code-block:: R
+
+    install.packages("xgboost")
+
+.. note:: Using all CPU cores (threads) on Mac OSX
+
+   If you are using Mac OSX, you should first install OpenMP library (``libomp``) by running
+
+   .. code-block:: bash
+
+        brew install libomp
+
+   and then run ``install.packages("xgboost")``. Without OpenMP, XGBoost will only use a
+   single CPU core, leading to suboptimal training speed.
+
 JVM
 ---
 


Reviews:
user: login: david-cortes
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-26T17:47:00Z

Review comments:
diff_hunk: @@ -17,9 +17,16 @@ You have found the XGBoost R Package!
 Get Started
 ***********
 
-* Checkout the :doc:`Installation Guide </install>` contains instructions to install xgboost, and :doc:`Tutorials </tutorials/index>` for examples on how to use XGBoost for various tasks.
-* Read the latest `API documentation <../r_docs/R-package/docs/reference/index.html>`__ . This might refer to a newer version than the one on CRAN.
-* Read the `CRAN documentation <https://cran.r-project.org/web/packages/xgboost/xgboost.pdf>`_.
+Since XGBoost 3.0.0, the latest R package is available on
+`https://dmlc.r-universe.dev/builds <R-universe>`__ while the one on CRAN is kept at an
+older version. We will work on helping the CRAN version to catch up in the future. In the
+meanwhile, please use R-universe packages.
path: doc/R-package/index.rst
user: login: david-cortes
body: ```suggestion
meantime, please use R-universe packages.
```
created_at: 2025-03-26T17:44:44Z
author_association: CONTRIBUTOR
diff_hunk: @@ -17,9 +17,16 @@ You have found the XGBoost R Package!
 Get Started
 ***********
 
-* Checkout the :doc:`Installation Guide </install>` contains instructions to install xgboost, and :doc:`Tutorials </tutorials/index>` for examples on how to use XGBoost for various tasks.
-* Read the latest `API documentation <../r_docs/R-package/docs/reference/index.html>`__ . This might refer to a newer version than the one on CRAN.
-* Read the `CRAN documentation <https://cran.r-project.org/web/packages/xgboost/xgboost.pdf>`_.
+Since XGBoost 3.0.0, the latest R package is available on
+`https://dmlc.r-universe.dev/builds <R-universe>`__ while the one on CRAN is kept at an
+older version. We will work on helping the CRAN version to catch up in the future. In the
+meanwhile, please use R-universe packages.
+
+* Checkout the :doc:`Installation Guide </install>` contains instructions to install
path: doc/R-package/index.rst
user: login: david-cortes
body: ```suggestion
* Check out the :doc:`Installation Guide </install>` for instructions on how to install
```
created_at: 2025-03-26T17:46:00Z
author_association: CONTRIBUTOR

PR comments:
user: login: trivialfis
created_at: 2025-03-26T15:58:47Z
body: cc @david-cortes @hcho3 
author_association: MEMBER
user: login: david-cortes
created_at: 2025-03-26T17:07:27Z
body: Thanks, can confirm that it works for me under windows and linux.
author_association: CONTRIBUTOR
user: login: trivialfis
created_at: 2025-03-26T17:31:39Z
body: @david-cortes Thank you for the test, could you please help review the changes when you are available?
author_association: MEMBER