【问题标题】:Error trying to install R package (mirt) from source尝试从源代码安装 R 包(mirt)时出错
【发布时间】:2020-07-27 17:00:35
【问题描述】:

我正在尝试从源代码安装 R 包 mirt,但收到错误消息。我在 PC 和 Mac 上都收到错误消息。请注意,我的 PC 和 Mac 都设置为从源代码安装软件包,并且我已在两个系统上成功地从源代码安装软件包。例如,我已经验证我可以使用以下命令在我的 PC 和 Mac 上从源代码成功安装包 jsonliteinstall.packages("jsonlite", type = "source")。我在我的 PC 和 Xcode 上安装了Rtools 4.0,在我的 Mac 上安装了R Compiler Toolsmirt 包的创建者 Phil Chalmers 建议我的编译器可能需要重新配置(因为看起来 g++.exe 不在 R 可以看到的路径中)。我该如何解决这个问题,以便我可以从源代码安装 mirt 包?

这是我在我的 PC 上尝试从源代码安装时收到的错误:

> install.packages('mirt', type = 'source')
Installing package into ‘C:/R/Packages’
(as ‘lib’ is unspecified)
trying URL 'https://cran.r-project.org/src/contrib/mirt_1.32.1.tar.gz'
Content type 'application/x-gzip' length 811759 bytes (792 KB)
downloaded 792 KB


Welcome at Tue Jul 28 22:32:44 2020 
* installing *source* package 'mirt' ...
** package 'mirt' successfully unpacked and MD5 sums checked
** using staged installation
** libs

*** arch - i386
"C:/rtools40/mingw32/bin/"g++ -std=gnu++11  -I"C:/R/R-40~1.2/include" -DNDEBUG  -I'C:/R/Packages/Rcpp/include' -I'C:/R/Packages/RcppArmadillo/include'     -fopenmp   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c Estep.cpp -o Estep.o
"C:/rtools40/mingw32/bin/"g++ -std=gnu++11  -I"C:/R/R-40~1.2/include" -DNDEBUG  -I'C:/R/Packages/Rcpp/include' -I'C:/R/Packages/RcppArmadillo/include'     -fopenmp   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c Misc.cpp -o Misc.o
"C:/rtools40/mingw32/bin/"g++ -std=gnu++11  -I"C:/R/R-40~1.2/include" -DNDEBUG  -I'C:/R/Packages/Rcpp/include' -I'C:/R/Packages/RcppArmadillo/include'     -fopenmp   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c dpars.cpp -o dpars.o
"C:/rtools40/mingw32/bin/"g++ -std=gnu++11  -I"C:/R/R-40~1.2/include" -DNDEBUG  -I'C:/R/Packages/Rcpp/include' -I'C:/R/Packages/RcppArmadillo/include'     -fopenmp   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c ggum_derivs.cpp -o ggum_derivs.o
"C:/rtools40/mingw32/bin/"g++ -std=gnu++11  -I"C:/R/R-40~1.2/include" -DNDEBUG  -I'C:/R/Packages/Rcpp/include' -I'C:/R/Packages/RcppArmadillo/include'     -fopenmp   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c traceLinePts.cpp -o traceLinePts.o
C:/rtools40/mingw32/bin/g++ -std=gnu++11 -shared -s -static-libgcc -o mirt.dll tmp.def Estep.o Misc.o dpars.o ggum_derivs.o traceLinePts.o Welcome at Tue Jul 28 22:33:21 2020 Goodbye at Tue Jul 28 22:33:21 2020 -LC:/R/R-40~1.2/bin/i386 -lRlapack -LC:/R/R-40~1.2/bin/i386 -lRblas -lgfortran -lm -lquadmath -fopenmp -LC:/R/R-40~1.2/bin/i386 -lR
g++.exe: error: Welcome: No such file or directory
g++.exe: error: at: No such file or directory
g++.exe: error: Tue: No such file or directory
g++.exe: error: Jul: No such file or directory
g++.exe: error: 28: No such file or directory
g++.exe: error: 22:33:21: Invalid argument
g++.exe: error: 2020: No such file or directory
g++.exe: error: Goodbye: No such file or directory
g++.exe: error: at: No such file or directory
g++.exe: error: Tue: No such file or directory
g++.exe: error: Jul: No such file or directory
g++.exe: error: 28: No such file or directory
g++.exe: error: 22:33:21: Invalid argument
g++.exe: error: 2020: No such file or directory
no DLL was created
ERROR: compilation failed for package 'mirt'
* removing 'C:/R/Packages/mirt'
* restoring previous 'C:/R/Packages/mirt'
Warning in install.packages :
  installation of package ‘mirt’ had non-zero exit status

The downloaded source packages are in
    ‘C:\Users\Isaac\AppData\Local\Temp\RtmpwfAN3M\downloaded_packages’

会话信息:

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.0.2 tools_4.0.2

验证 Rtools 4.0 是否已安装:

> Sys.which("make")
                              make 
"C:\\rtools40\\usr\\bin\\make.exe" 

但是,R 似乎无法识别 g++.exe 的位置:

> system("g++ -v")
[1] 127

【问题讨论】:

    标签: r package g++ installation-package rtools


    【解决方案1】:

    我最终能够弄清楚这一点。出现此问题是因为我的 Rprofile.site 文件将文本打印到控制台:

    .First <- function(){
      cat("\nWelcome at", date(), "\n")
    }
    
    .Last <- function(){
      cat("\nGoodbye at ", date(), "\n")
    }
    
    

    问题在于,正如这里所指出的,“这台机器上.Rprofilecat 输出似乎被插入到g++ 命令中。删除cat 调用后,库安装没有错误。”

    在注释掉RProfile.site 文件中的cat 调用后,我能够成功地从源代码安装包。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-03
      • 2010-12-01
      相关资源
      最近更新 更多