0

I am attempting to install MatchIt - an R package - in an Anaconda environment. I keep getting error messages that I just don't understand.

I made sure that I had Rcpp installed in the same Conda environment and that I have Xcode installed on my machine. Still no luck. I was wondering if anyone had a solution.

devtools::install_github('kosukeimai/MatchIt')
Downloading GitHub repo kosukeimai/MatchIt@HEAD
✔  checking for file ‘/private/var/folders/cz/1d4gc7b13dsfknrnbr0tjz580000gn/T/RtmpYISSL1/remotes50d505ff397/kosukeimai-MatchIt-b3032e6/DESCRIPTION’ ...
─  preparing ‘MatchIt’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
─  installing the package to process help pages
         -----------------------------------
─  installing *source* package ‘MatchIt’ ...
   ** using staged installation
   ** libs
   x86_64-apple-darwin13.4.0-clang++ -std=gnu++11 -I"/opt/anaconda3/envs/pirate/lib/R/include" -DNDEBUG  -I'/opt/anaconda3/envs/pirate/lib/R/library/Rcpp/include' -I'/opt/anaconda3/envs/pirate/lib/R/library/RcppProgress/include' -D_FORTIFY_SOURCE=2 -isystem /opt/anaconda3/envs/pirate/include -mmacosx-version-min=10.9 -I/opt/anaconda3/envs/pirate/include   -fPIC  -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden  -fmessage-length=0 -isystem /opt/anaconda3/envs/pirate/include -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/r-base-split_1630154249442/work=/usr/local/src/conda/r-base-4.1.1 -fdebug-prefix-map=/opt/anaconda3/envs/pirate=/usr/local/src/conda-prefix  -Wall -pedantic -c RcppExports.cpp -o RcppExports.o
   /bin/sh: x86_64-apple-darwin13.4.0-clang++: command not found
   make: *** [RcppExports.o] Error 127
   ERROR: compilation failed for package ‘MatchIt’
─  removing ‘/private/var/folders/cz/1d4gc7b13dsfknrnbr0tjz580000gn/T/RtmpeKesPi/Rinst1a5f6063566d/MatchIt’
         -----------------------------------
   ERROR: package installation failed
Error: Failed to install 'MatchIt' from GitHub:
  System command 'R' failed, exit status: 1, stdout + stderr (last 10 lines):
E> * installing *source* package ‘MatchIt’ ...
E> ** using staged installation
E> ** libs
E> x86_64-apple-darwin13.4.0-clang++ -std=gnu++11 -I"/opt/anaconda3/envs/pirate/lib/R/include" -DNDEBUG  -I'/opt/anaconda3/envs/pirate/lib/R/library/Rcpp/include' -I'/opt/anaconda3/envs/pirate/lib/R/library/RcppProgress/include' -D_FORTIFY_SOURCE=2 -isystem /opt/anaconda3/envs/pirate/include -mmacosx-version-min=10.9 -I/opt/anaconda3/envs/pirate/include   -fPIC  -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden  -fmessage-length=0 -isystem /opt/anaconda3/envs/pirate/include -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/r-base-split_1630154249442/work=/usr/local/src/conda/r-base-4.1.1 -fdebug-prefix-map=/opt/anaconda3/envs/pirate=/usr/local/src/conda-prefix  -Wall -pedant

I have also looked around on the Conda-forge channel to see if I could just conda install -c conda-forge r-MatchIt but no luck either.

  • One should really avoid using `install.packages` in Conda R environments, especially when compilation is involved. It would preferable if users contributed to the community and added the missing packages they need to Conda Forge (see https://stackoverflow.com/a/69921221/570918). – merv Feb 09 '22 at 20:11
  • FYI: [a PR](https://github.com/conda-forge/staged-recipes/pull/17983) is now submitted to add it to Conda Forge. Might be some delay, due to Azure pipeline issues. – merv Feb 09 '22 at 20:19
  • Thanks so much for adding it to conda forge. I didn’t know what the process was for that so I appreciate the link to the thread. – Damon C. Roberts Feb 09 '22 at 22:48
  • 1
    Should now be available via `conda install -c conda-forge r-matchit`. – merv Feb 11 '22 at 14:28

1 Answers1

0

I ended up getting the package to install and compile but I am not exactly sure how.

I deleted then reinstalled Xcode.

I then accessed R in my conda environment via terminal and tried reinstalling the package that way with pgkbuild().

$ conda activate pirate
$ R
> pkgbuild::check_build_tools(devtools::install_github('kosukeimai/MatchIt'), debug = TRUE)

I obviously don't really understand how any of the Clang compiling works, but if this can be useful for someone as clueless as I am, I guess the ole classic of deleting and reinstalling Xcode will do it.