Issue
I'm running Miniconda3 on Ubuntu 20.04 LTS OS and have installed R-4.0.3 in a conda environment. When I try to install packages from CRAN repositoriesvia R prompt, I get a
class="lang-sh prettyprint-override">x86_64-conda-linux-gnu-c++: not found
I have run source activate qwe
(qwe
is the name of the environment) as advised in Anaconda documentation on built-in gcc tool chain. I also ran source activate root
and installed the compiler tool chain using conda install gxx_linux-64
My $PATH
returns the following:
/home/sreedta/miniconda3/envs/qwe/bin:/home/sreedta/miniconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Here is the full output when I tried to install a package called bayesm
> install.packages("bayesm")
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://cloud.r-project.org/src/contrib/bayesm_3.1-4.tar.gz'
Content type 'application/x-gzip' length 2269364 bytes (2.2 MB)
==================================================
downloaded 2.2 MB
* installing *source* package ‘bayesm’ ...
** package ‘bayesm’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
x86_64-conda-linux-gnu-c++ -std=gnu++11 -I"/home/sreedta/miniconda3/envs/qwe/lib/R/include" -DNDEBUG -I../inst/include/ -I'/home/sreedta/miniconda3/envs/qwe/lib/R/library/Rcpp/include' -I'/home/sreedta/miniconda3/envs/qwe/lib/R/library/RcppArmadillo/include' -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/sreedta/miniconda3/envs/qwe/include -I/home/sreedta/miniconda3/envs/qwe/include -Wl,-rpath-link,/home/sreedta/miniconda3/envs/qwe/lib -fpic -fvisibility-inlines-hidden -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/sreedta/miniconda3/envs/qwe/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/r-base_1603047469992/work=/usr/local/src/conda/r-base-4.0.3 -fdebug-prefix-map=/home/sreedta/miniconda3/envs/qwe=/usr/local/src/conda-prefix -c RcppExports.cpp -o RcppExports.o
/bin/sh: 1: x86_64-conda-linux-gnu-c++: not found
make: *** [/home/sreedta/miniconda3/envs/qwe/lib/R/etc/Makeconf:180: RcppExports.o] Error 127
ERROR: compilation failed for package ‘bayesm’
* removing ‘/home/sreedta/miniconda3/envs/qwe/lib/R/library/bayesm’
* restoring previous ‘/home/sreedta/miniconda3/envs/qwe/lib/R/library/bayesm’
The downloaded source packages are in
‘/tmp/Rtmp6hsphd/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("bayesm") :
installation of package ‘bayesm’ had non-zero exit status
Solution
If you have R in a Conda environment, I would strongly recommend avoiding installs through utils::install.packages
. Instead, install through Conda. Many CRAN packages are available through the Conda Forge channel, usually with an "r-" prepended to the package name. So, try
conda install -n qwe -c conda-forge r-bayesem
Answered By - merv Answer Checked By - Robin (WPSolving Admin)