无法安装 R 包:CMake 错误

cannot install R package: CMake errorr

我正在尝试安装 factoextra,但我在 CMake 部分卡住了,特别是错误,例如:

CMake Error: The source directory "/tmp/..." does not exist.

(当我尝试安装其依赖项时也是如此:nloptrpbkrtestlme4carrstatixFactoMineR , ggpubr )

有什么想法吗?

谢谢

ps:

日志的最后一部分:

CMake Error: The source directory "/tmp/RtmpgJySdf/R.INSTALL20c31df42f6/nloptr/src/nlopt-build" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
Unknown argument -j
Unknown argument 2
Usage: cmake --build <dir> [options] [-- [native-options]]
Options:
  <dir>          = Project binary directory to be built.
  --target <tgt> = Build <tgt> instead of default targets.
  --config <cfg> = For multi-configuration tools, choose <cfg>.
  --clean-first  = Build target 'clean' first, then build.
                   (To clean only, use --target 'clean'.)
  --use-stderr   = Don't merge stdout/stderr output and pass the
                   original stdout/stderr handles to the native
                   tool so it can use the capabilities of the
                   calling terminal (e.g. colored output).
  --             = Pass remaining options to the native tool.
CMake Error: The source directory "/tmp/RtmpgJySdf/R.INSTALL20c31df42f6/nloptr/src/nlopt" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
cp: cannot stat 'nlopt/include/*': No such file or directory
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I"/opt/R/4.0.0/lib/R/include" -DNDEBUG -I../inst/include  -I'/opt/R/4.0.0/lib/R/library/testthat/include' -I/usr/local/include   -fpic  -g -O2  -c init_nloptr.c -o init_nloptr.o
gcc -std=gnu99 -I"/opt/R/4.0.0/lib/R/include" -DNDEBUG -I../inst/include  -I'/opt/R/4.0.0/lib/R/library/testthat/include' -I/usr/local/include   -fpic  -g -O2  -c nloptr.c -o nloptr.o
g++ -std=gnu++11 -I"/opt/R/4.0.0/lib/R/include" -DNDEBUG -I../inst/include  -I'/opt/R/4.0.0/lib/R/library/testthat/include' -I/usr/local/include   -fpic  -g -O2  -c test-C-API.cpp -o test-C-API.o
g++ -std=gnu++11 -I"/opt/R/4.0.0/lib/R/include" -DNDEBUG -I../inst/include  -I'/opt/R/4.0.0/lib/R/library/testthat/include' -I/usr/local/include   -fpic  -g -O2  -c test-runner.cpp -o test-runner.o
g++ -std=gnu++11 -shared -L/opt/R/4.0.0/lib/R/lib -L/usr/local/lib -o nloptr.so init_nloptr.o nloptr.o test-C-API.o test-runner.o -L/opt/R/4.0.0/lib/R/lib -lRlapack -L/opt/R/4.0.0/lib/R/lib -lRblas -lgfortran -lm -lquadmath -Lnlopt/lib -lnlopt -L/opt/R/4.0.0/lib/R/lib -lR
/bin/ld: cannot find -lnlopt
collect2: error: ld returned 1 exit status
make: *** [nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/opt/R/4.0.0/lib/R/library/nloptr’
ERROR: dependency ‘nloptr’ is not available for package ‘lme4’
* removing ‘/opt/R/4.0.0/lib/R/library/lme4’
ERROR: dependency ‘lme4’ is not available for package ‘pbkrtest’
* removing ‘/opt/R/4.0.0/lib/R/library/pbkrtest’
ERROR: dependencies ‘pbkrtest’, ‘lme4’ are not available for package ‘car’
* removing ‘/opt/R/4.0.0/lib/R/library/car’
ERROR: dependency ‘car’ is not available for package ‘rstatix’
* removing ‘/opt/R/4.0.0/lib/R/library/rstatix’
ERROR: dependency ‘car’ is not available for package ‘FactoMineR’
* removing ‘/opt/R/4.0.0/lib/R/library/FactoMineR’
ERROR: dependency ‘rstatix’ is not available for package ‘ggpubr’
* removing ‘/opt/R/4.0.0/lib/R/library/ggpubr’
ERROR: dependencies ‘FactoMineR’, ‘ggpubr’ are not available for package ‘factoextra’
* removing ‘/opt/R/4.0.0/lib/R/library/factoextra’

The downloaded source packages are in
    ‘/tmp/Rtmp98DJqK/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning messages:
1: In install.packages("factoextra") :
  installation of package ‘nloptr’ had non-zero exit status
2: In install.packages("factoextra") :
  installation of package ‘lme4’ had non-zero exit status
3: In install.packages("factoextra") :
  installation of package ‘pbkrtest’ had non-zero exit status
4: In install.packages("factoextra") :
  installation of package ‘car’ had non-zero exit status
5: In install.packages("factoextra") :
  installation of package ‘rstatix’ had non-zero exit status
6: In install.packages("factoextra") :
  installation of package ‘FactoMineR’ had non-zero exit status
7: In install.packages("factoextra") :
  installation of package ‘ggpubr’ had non-zero exit status
8: In install.packages("factoextra") :
  installation of package ‘factoextra’ had non-zero exit status

我通过 sudo apt-get install libnlopt-dev 解决了这个问题。

所以,

我想我终于明白了!
factoextra(或更好,nloptr)目前需要 组合

在Ubuntu中从源安装cmake v3.20.2,它将解决问题:

sudo apt install build-essential libssl-dev
wget https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2.tar.gz
tar -zxvf cmake-3.20.2.tar.gz
cd cmake-3.20.2
./bootstrap
make 
sudo make install