1

I'm trying to install the R package mirt from source, but am receiving errors. I am receiving errors on both PC and Mac. Note that both my PC and Mac are set up to install packages from source, and I have successfully installed packages from source on both systems. For instance, I have verified that I can successfully install the package jsonlite from source on both my PC and Mac with the following command: install.packages("jsonlite", type = "source"). I have Rtools 4.0 installed on my PC and Xcode and R Compiler Tools installed on my Mac. Phil Chalmers, the creator of the mirt package, suggested that my compilers might need to be reconfigured (as it looks like g++.exe is not in a path that R can see). How can I fix this so I can install the mirt package from source?

Here's the error I receive when trying to install from source on my 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’

Session Info:

> 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

Verification that Rtools 4.0 is installed:

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

However, R doesn't seem to recognize where g++.exe is:

> system("g++ -v")
[1] 127
itpetersen
  • 1,475
  • 3
  • 13
  • 32

1 Answers1

1

I was eventually able to figure this out. This problem arose because my Rprofile.site file prints text to the console:

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

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

The problem is that, as noted here, "It appears that the cat output from the .Rprofile on this machine is being inserted into the g++ command. After removing the cat call, the library installs without error."

After commenting out the cat calls in the RProfile.site file, I was able to successfully install the package from source.

itpetersen
  • 1,475
  • 3
  • 13
  • 32