Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"/bin/sh: XX: command not found" error when trying to install development version of R fst package from github

I'm trying to install the development version of the fst package from github. (I want the development version because it maintains column classes when saving data frames, whereas the current released version does not.)

Initially, installation failed due to lack of OpenMP support. I resolved this (I think) by following the steps here for R 3.4.0 on OSX.

However, now I'm getting the following error: /bin/sh: XX: command not found. I've already set what are supposed to be the appropriate paths in the ~/.R/Makevars file, so I'm not sure what to do next to resolve the error.

Here's my code and output:

First attempt to install fst, before adding OpenMP support

devtools::install_github("fstPackage/fst", ref = "develop")

* installing *source* package ‘fst’ ...
** libs
clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -fopenmp -I. -Ifstcore -Ifstcore/LZ4 -Ifstcore/ZSTD -Ifstcore/ZSTD/common -Ifstcore/ZSTD/decompress -Ifstcore/ZSTD/compress -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include -fPIC -Wall -g -O2 -c FastStore.cpp -o FastStore.o
clang: error: unsupported option '-fopenmp'
make: *** [FastStore.o] Error 1
ERROR: compilation failed for package ‘fst’

Adding OpenMP support

To add OpenMP support, I followed the steps here for R 3.4.0, including installing gfortran 6.1 from here and clang using the pre-built OSX GUI installer provided here. Then, as instructed, I added the following to my ~/.R/Makevars file:

CC=/usr/local/clang4/bin/clang
CXX=/usr/local/clang4/bin/clang++
CXX11=$CXX
CXX14=$CXX
CXX17=$CXX
CXX1X=$CXX
LDFLAGS=-L/usr/local/clang4/lib

Second attempt to install fst

I then ran the installation code again and got the following error:

devtools::install_github("fstPackage/fst", ref = "develop")

* installing *source* package ‘fst’ ...
** libs
XX -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -fopenmp -I. -Ifstcore -Ifstcore/LZ4 -Ifstcore/ZSTD -Ifstcore/ZSTD/common -Ifstcore/ZSTD/decompress -Ifstcore/ZSTD/compress -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c FastStore.cpp -o FastStore.o
/bin/sh: XX: command not found
make: *** [FastStore.o]
Error 127 ERROR: compilation failed for package ‘fst’

In addition to the errors, I can see that the installation output begins with clang++ -std=gnu++11 ... in the first attempt and XX -std=gnu++11 ... in the second attempt. I'm guessing I need to tell R (or some other program) about the path to clang, but I'm not sure what path is needed or where to put it (and isn't the Makevars file supposed to take care of that?), or whether there are other issues that need to be fixed as well.

Here are some of the particulars about my system:

Macbook Pro, OSX Sierra (version 10.12.5)

RStudio version 1.0.153

R Session Info

R version 3.4.1 (2017-06-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.5

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

loaded via a namespace (and not attached):
 [1] httr_1.2.1      compiler_3.4.1  R6_2.2.2        tools_3.4.1     withr_1.0.2    
 [6] curl_2.8.1      memoise_1.1.0   git2r_0.19.0    digest_0.6.12   devtools_1.13.2

UPDATE: Based on @MarkPlotnick's comment, I changed Makevars to the following:

CC=/usr/local/clang4/bin/clang
CXX=/usr/local/clang4/bin/clang++
CXX11=$(CXX)
CXX14=$(CXX)
CXX17=$(CXX)
CXX1X=$(CXX)
LDFLAGS=-L/usr/local/clang4/lib

This resulted in the following error:

* installing source package ‘fst’ ...
** libs /Users/eipi10/.R/Makevars:7: *** Recursive variable `CXX' references itself (eventually). Stop.
ERROR: compilation failed for package ‘fst’

like image 830
eipi10 Avatar asked Jul 28 '17 19:07

eipi10


1 Answers

I ran into the issue and figured out the solution based on the comment by @Dirk in "/bin/sh: XX: command not found" error when trying to install development version of R fst package from github

I explicitly set the libraries in .R/Makevars:

CXX11=/usr/local/clang4/bin/clang++
CXX14=/usr/local/clang4/bin/clang++
CXX17=/usr/local/clang4/bin/clang++
CXX1X=/usr/local/clang4/bin/clang++

This worked for me when I encountered this problem, though on my Mac the path to the binary is /Library/Developer/CommandLineTools/usr/bin/clang++)

like image 157
David LeBauer Avatar answered Nov 11 '22 08:11

David LeBauer