When I attempt to install certain packages (e.g., glmnet) for R within RStudio, I get an error like g++-7: command not found.
Why is this occurring and what can be done about it?
When I attempt to install certain packages (e.g., glmnet) for R within RStudio, I get an error like g++-7: command not found.
Why is this occurring and what can be done about it?
The error g++-7: command not found tells us R is using an unexpected command to build the package on your system. The typical command for building packages written in C++ on Linux systems is g++, without the trailing -7.
On our system, we found that this error is caused by a line in an unexpected file. The file is ~/.R/Makevars and contains the following line.
CXX17 = g++-7 -std=gnu++17 -fPIC
The line causes the build tool make to use the g++-7 executable instead of the typical g++ whenever C++17 is being compiled. The g++-7 executable doesn’t exist on our system, hence the error command not found.
To resolve the issue, delete the unexpected file using rm ~/.R/Makevars.