

In RStudio editor and in R console, ‘alt’ + ‘-‘ gives us ‘<-'.
This is indeed very trivial but really deserves a post!
In RStudio editor and in R console, alt
+ -
gives us <-
.
Such great news for my fingers!
I have never considered myself a good developer. Coding activities such as writing some functions in Rcpp for an R package and building my personal website (nianqiaoju.github.io) already makes me proud.
Last night, I had some trouble building a package in RStudio. At the beginning, I thought it was because I accidentally included a test file in the ProjectDirectory/R
folder, but it was not the case. So I had no choice but to read the error messages carefully.
I did not keep a record of this, but important bits of the messages look like:
ld: unknown option: -platform_version
clang: error: linker command failed with exit code 1 (use -v to see invocation)
That’s when I started to realize that this had to do with a recent MacOS update and probably my package was fine. Interestingly, I did not recall authorizing a system update and learned about this only through running sessionInfo()
in console. These are some trouble shooting steps I did in RStudio console:
devtools::load_all()
–>> leads to error messagesRcpp::evalCpp("2+2")
–>> leads to error messages.It seemed like the operating system update has ‘disabled’ my R compiler tools for RCpp. Unfortunately, despite the huge amount of information on stack-overflow and github issues, I did not see any error messages matching exactly what I saw and there were some conflicting information. Moreover, I did not want to install the whole XCode app or to cause any irreversible damages. After one hour of trial and errors, below is what I think solved my crisis.
xcode-select --install
and it turns out my command line tools are already installed since the message xcode-select: error: command line tools are already installed, use "Software Update" to install updates.
gcc --version
and this is to confirm that the command gcc
is recognized by my terminal.~/.R/Makevars
to point to the system headers. I did it with vim: add the following lines to the file and comment out what’s already there.
# clang: start
CFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CCFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CXXFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
# clang: end
I believe that the last step did the magic for me and I was able to build packages from source without any trouble.
In this process this stack-overflow discussion and this blogpost were the most helpful.