This is my first time trying to download a Github package, and I'm running into some trouble using RStudio v1.2.5033 on MacOS Big Sur v11.2.1.
Initially, when running
library(devtools)
devtools::install_github('xuyiqing/gsynth')
I was getting this error:
Warning in install.packages :
installation of package ‘gsynth’ had non-zero exit status
Did some reading, and it looked like I needed to download Command Line Tools, so I downloaded XCode CLI, clang4, and gfortran. Now I am getting a pop-up message saying:
"Install Build Tools Building R package from source requires installation of additional build tools. Do you want to install the additional tools now? Y/N"
If I click "No", I get this error:
Error: Failed to install 'gsynth' from GitHub:
Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.
Running the above pkgbuild code in an R console, this is what I get:
Trying to compile a simple C file
Error: Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.
rror: Could not find tools necessary to compile a package
The devtools package contains functions that help with R package development. These functions include create , which creates the initial structure for a new package, as well as a number of functions for adding useful infrastructure to the package directory and functions to load and document the package.
Looks like there are a few issues that you need to overcome to install this package (xcode command line tools and OpenMP support for a start), but you should overcome them if you follow the instructions here: https://stackoverflow.com/a/65334247/12957340
After making the necessary changes, I successfully installed gsynth on my system (macOS Big Sur 11.2.3 / R version 4.0.3) using devtools::install_github('xuyiqing/gsynth')
without issue.
--
Here are the instructions in case the link above dies:
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
# This can take several hours
brew install gcc
brew install llvm
brew cleanup
brew update
brew upgrade
brew reinstall gcc
brew reinstall llvm
sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/
# You can safely ignore warnings like this:
#ln: /usr/local/include//tcl.h: File exists
#ln: /usr/local/include//tclDecls.h: File exists
#ln: /usr/local/include//tclPlatDecls.h: File exists
#ln: /usr/local/include//tclTomMath.h: File exists
#ln: /usr/local/include//tclTomMathDecls.h: File exists
#ln: /usr/local/include//tk.h: File exists
#ln: /usr/local/include//tkDecls.h: File exists
#ln: /usr/local/include//tkPlatDecls.h: File exists
~/.R/Makevars
file (if you already have a ~/.R/Makevars
file, save it in a different directory (away from ~/.R/
)) and include only these lines in the file:FLIBS=-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin19/10.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
CXX1X=/usr/local/gfortran/bin/g++
CXX98=/usr/local/gfortran/bin/g++
CXX11=/usr/local/gfortran/bin/g++
CXX14=/usr/local/gfortran/bin/g++
CXX17=/usr/local/gfortran/bin/g++
LLVM_LOC = /usr/local/opt/llvm
CC=/usr/local/gfortran/bin/gcc -fopenmp
CXX=/usr/local/gfortran/bin/g++ -fopenmp
CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
LDFLAGS=-L/usr/local/opt/gettext/lib -L$(LLVM_LOC)/lib -Wl,-rpath,$(LLVM_LOC)/lib
CPPFLAGS=-I/usr/local/opt/gettext/include -I$(LLVM_LOC)/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
# To check whether openmp is enabled, compile data.table:
install.packages("data.table", type = "source")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With