Error at RPackageInstall Windows 10

Previously had xgboost installed on this machine but need to reinstall due to a graphics card change.

Following the steps for GPU supported R installation here: https://xgboost.readthedocs.io/

Environment details:
Windows 10 Pro
cmake 3.19.1
CUDA 11.1
R 4.0.2

cmake appears to execute correctly using: cmake … -G"Visual Studio 16 2019" -A x64 -DR_LIB=ON -DUSE_CUDA=ON -DLIBR_EXECUTABLE=“C:\Program Files\R\R-4.0.2\bin\R.exe” -DR_VERSION=4.0.2

However during the build step I get:

Command: C:/Program Files/R/R-4.0.2/bin/R.exe CMD INSTALL --no-multiarch --build C:/Users/[user]/xgboost/build/R-package-install/R-package
  CMake Error at RPackageInstall.cmake:16 (message):
    out: , err: * installing to library
    'C:/Users/[user]/Documents/R/win-library/4.0'
    * installing *source* package 'xgboost' ...

    ** using staged installation

    Warning in system("sh ./configure.win") : 'sh' not found

EXEC : error : configuration failed for package 'xgboost' [C:\Users[user]\xgboost\build\install.vcxproj]

Tried updating xgboost from CRAN using install.packages(“xgboost”).
Tried reinstalling c(‘data.table’, ‘magrittr’, ‘stringi’).
Tried updating cmake.

Weirdly, xgboost will run in R but with no GPU support so it appears the install partially worked? But that could just be there being enough remnets of the old install there to let it run on CPU.

Any help would be appreciated

Make sure to install the Rtools40 and register the Rtools in the PATH environment variable. See https://cran.r-project.org/bin/windows/Rtools/

I do have rtools40 installed and on the path, sorry I should have mentioned that

Are both C:\rtools40\usr\bin and C:\rtools40\mingw64\bin in the PATH? The error messages says that sh is not found.

I had C:\rtools40\mingw64\bin in the PATH but not C:\rtools40\usr\bin. Not sure why the install worked last time without it.

Appreciate the help!