conda build R package fails due to C compiler - r

I'm trying to install an R package called rcdd using conda build and there is a problem with the C compiler. Note that this problem looks very similar to
Conda build R package fails at C compiler issue on MacOS Mojave however as (i) that question remains unanswered, and (ii) this relates to different package, I think this is not a duplicate question.
I'm using MacOS Mojave, conda 4.6.8. In a new conda environment with r-base and r-essentials
installed, I try
conda install conda-build
conda skeleton cran --recursive rcdd
conda build r-rcdd
and get the following error
* installing *source* package ‘rcdd’ ...
** package ‘rcdd’ successfully unpacked and MD5 sums checked
checking for gcc... x86_64-apple-darwin13.4.0-clang
checking whether the C compiler works... no
configure: error: in `/Users/pjethwa/miniconda3/envs/r_env/conda-bld/r-rcdd_1553173041138/work':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘rcdd’
The config.log file contains the same error message. This same error also appears when I try to install directly from R - i.e. using install.packages('rcdd'). I am able, however, to install this package using a version of R which was not installed by conda. This solution is unsatisfactory as I would like to use rpy2 to interface python and R, which seems to require that R be installed by conda (e.g. see Getting Segmentation fault Core dumped error while importing robjects from rpy2)
My clang/gcc versions are:
(r_env) myusername:~ clang --version
clang version 4.0.1 (tags/RELEASE_401/final)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Users/myusername/miniconda3/envs/r_env/bin
(r_env) myusername:~ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Related

Problems installing R packages-C compilers on macOS Catalina 10.15.4

I am having issues installing R packages in a conda environment on MacOS 10.15.4. The command install.packages() in R leads to the following type of errors (I am not pasting the full log):
ld: symbol(s) not found for architecture x86_64
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
Error 1
ERROR: compilation failed for package ‘xml2’
checking for gcc... x86_64-apple-darwin13.4.0-clang
checking whether the C compiler works... no
configure: error: in `/private/var/folders/k6/p2cdz1dx32g3p4hmwghns3fc0000gn/T/RtmpdPz2VA/R.INSTALL4817a82715f/uuid':
configure: error: C compiler cannot create executables
I am using r version 3.6.1 on a platform x86_64-apple-darwin13.4.0
The clang version is:
clang version 4.0.1 (tags/RELEASE_401/final)
Target: x86_64-apple-darwin19.4.0
Thread model: posix
InstalledDir: /opt/anaconda3/envs/r_omics/bin
So I assumed there was an issue/conflict with the way the C compilers on my computer process R-packages installation but I don't know how to solve this.
Somehow I manage to install some of the packages through conda install but I don't manage through this to recover the environment I need.
Thank you very much for your help

Cannot compile R packages under Conda

OK, this is driving me crazy.
I'm attempting to use Conda as a quasi-package manager for R on my Mac (OS 10.15) as I have done (successfully) on other Unix installations.
Repeatedly, the error I get is the following
Before the creation of a new conda environment, we have:
$ gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
and
$ which clang
/usr/bin/clang
We create a new empty environment and check again
$ conda create --name r_env
$ conda activate r_env
$ gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ which clang
/usr/bin/clang
Great. So far so good.
Now we install R and check again.
$ conda install r=3.6
$ gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ which clang
/Users/dgarfield/miniconda3/envs/r_env/bin/clang
$ clang -v
clang version 4.0.1 (tags/RELEASE_401/final)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Users/dgarfield/miniconda3/envs/r_env/bin
It appears that we have a new clang!
Why is this a problem?
$ R
> install.packages("XML")
trying URL 'https://cran.uni-muenster.de/src/contrib/XML_3.98-1.20.tar.gz'
Content type 'application/x-gzip' length 1600829 bytes (1.5 MB)
==================================================
downloaded 1.5 MB
* installing *source* package ‘XML’ ...
** package ‘XML’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... x86_64-apple-darwin13.4.0-clang
checking whether the C compiler works... no
configure: error: in `/private/var/folders/dg/hbvl43fn0b7flfk6l__3bwth0000gq/T/Rtmplh4pEL/R.INSTALL12b2d7b634136/XML':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘XML’
* removing ‘/Users/dgarfield/miniconda3/envs/r_env/lib/R/library/XML’
The downloaded source packages are in
‘/private/var/folders/dg/hbvl43fn0b7flfk6l__3bwth0000gq/T/RtmpaiTLe8/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("XML") :
installation of package ‘XML’ had non-zero exit status
This works perfectly fine on a standard (non-Conda) installation. My guess is that the culprit is this new clang.
Following what I have seen elsewhere, I have tried this with
CONDA_BUILD_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
and
CONDA_BUILD_SYSROOT=/opt/MacOSX10.9.sdk
So it doesn't seem to be anything too weird with the headers (??). But I'm out of ideas and could use some guidance.
(and yes, I know that in the case of XML, conda could to the install for me, but that isn't the case for all packages).
Thanks!

Problems Installing rgeos and rgdal on Mac OS X High Sierra

I have looked at the multiple sources to figure out how to install rgeos and rgdal on Mac OS X High Sierra in a way that works with Anaconda Navigator. I mention Anaconda because I want to be able to build static project-specific, package environments to ensure that my projects work 6 months from now when the dependent packages change. I have successfully installed and used both rgeos and rgdal on a couple other computers but seem to be having issues on a new computer. I want to launch Shiny apps from Anaconda Navigator's RStudio. None of the solutions I found, listed below, worked:
https://dyerlab.ces.vcu.edu/2015/03/31/install-rgeos-on-osx/
https://cran.rstudio.com/web/packages/rgeos/rgeos.pdf
http://tlocoh.r-forge.r-project.org/mac_rgeos_rgdal.html
https://anaconda.org/conda-forge/r-rgdal
Based on the above sources and my slow progression through a series of error messages, I tried the following:
Install GDAL 2.2 Complete [30.0 MiB] 2018-3-10 from http://www.kyngchaos.com/software/frameworks. This installs GDAL, GEOS, PROJ, SQLite and UnixImageIO frameworks.
The above installed without an error message. But attempting to install rgeos gave an error message:
configure: error: geos-config not found or not executable.
Consequently, either the install failed and didn't notify me, or there is some type of $PATH issue (?). On a blog, someone suggested to do the following in response to the aforementioned issue:
brew install geos
The above completed successfully. So I went into RStudio and tried the following, which resolved the former error but produced a new one:
install.packages("~/Downloads/rgeos_0.3-28.tar.gz", repos = NULL, type = "source")
installing source package ‘rgeos’ ...
configure: CC: x86_64-apple-darwin13.4.0-clang
configure: CXX: x86_64-apple-darwin13.4.0-clang++
configure: rgeos: 0.3-28
checking for /usr/bin/svnversion... yes
cat: inst/SVN_VERSION: No such file or directory
configure: svn revision:
checking for geos-config... /usr/local/bin/geos-config
checking geos-config usability... yes
configure: GEOS version: 3.6.2
checking geos version at least 3.2.0... yes
checking geos-config clibs... yes
checking geos_c.h presence and usability... no
configure: error: geos_c.h not found in standard or given locations.
ERROR: configuration failed for package ‘rgeos’
removing ‘/Users/aloha2018/anaconda2/lib/R/library/rgeos’
Warning in install.packages :
installation of package ‘/Users/aloha2018/Downloads/rgeos_0.3-28.tar.gz’ had non-zero exit status
Any ideas on what to try next?
Naturally, I already tried in an RStudio application launched from Anaconda Navigator:
install.packages("rgeos")
install.packages("rgdal")
both from CRAN and from tar.gz. But it seems like it is unable to find a file called geos_c.h, which does indeed exist on my computer at:
/Library/Frameworks/GEOS.framework/Versions/3B/Headers/geos_c.h
Is there a way to tell RStudio to look in the directory containing that file so my rgeos and rgdal installations work? Are there other errors I should expect to encounter and if so, how do I avoid/resolve them?
I also tried in a Terminal window:
conda install -c conda-forge r-rgdal
but that fails after spending a long time attempting to "solve environment":
Andrews-MacBook-Pro:~ aloha2018$ conda install -c conda-forge r-rgdal
Solving environment: failed
UnsatisfiableError: The following specifications were found to be in conflict:
- r-rgdal
- rstudio==1.1.423
Use "conda info <package>" to see the dependencies for each package.
So I try:
conda r-rgdal
But there is no output:
Andrews-MacBook-Pro:~ aloha2018$ conda info r-rgdal
Andrews-MacBook-Pro:~ aloha2018$
I've had a similar issue. I first solved it by installing everything using conda using the following environment.yml configuration
name: london-crime-r
channels:
- conda-forge
- conda
dependencies:
- gdal
- geos
- r-base
- r-rcpp
- r-irkernel
- r-mass
- r-dplyr
- r-rgdal
- r-rgeos
- r-raster
- rstudio
However, after updating conda, resolving dependencies did not finish within the 10 hours so I went the traditional route:
Use brew to install geos and gdal. It takes 40 minutes to build on my machine.
brew install geos gdal
Once that has been achieved, install R packages in this sequence.
install.packages('sp', type='source')
install.packages("rgeos", repos="http://R-Forge.R-project.org", type="source")
require(rgeos)
install.packages("rgdal", repos="http://R-Forge.R-project.org", type="source")
require(rgdal)
Subsequently, the packages below are ok with the plain install.
libraries <- c("rgdal",
"rgeos",
"raster",
"spdep",
"spatstat")
install.packages(libraries)

Install R cairo package after installing cairo via conda

I'm trying to install the Cairo package for R. I don't have admin rights for the server so I installed Cairo via the conda package manager conda install -c https://conda.anaconda.org/anaconda cairo. I have compiled R from source in my home directory.
I have tried to add the following to my bashrc:
export CAIRO_LIBS=-L${HOME}/miniconda/pkgs/cairo-1.12.18-6/lib/cairo/
export CAIRO_CFLAGS=-I${HOME}/miniconda/pkgs/cairo-1.12.18-6/include/cairo/
When I try install.packages('Cairo'), I get the following error:
configure: CAIRO_CFLAGS=-I/N/u/jfreimer/Mason/miniconda/pkgs/cairo-1.12.18-6/include/cairo/
checking if R was compiled with the RConn patch... no
checking cairo.h usability... yes
checking cairo.h presence... yes
checking for cairo.h... yes
checking for PNG support in Cairo... yes
checking for ATS font support in Cairo... no
configure: CAIRO_LIBS=-L/N/u/jfreimer/Mason/miniconda/pkgs/cairo-1.12.18-6/lib/cairo/
checking for library containing deflate... -lz
checking whether Cairo programs can be compiled... configure: error: Cannot compile a simple Cairo program. See config.log for details.
ERROR: configuration failed for package ‘Cairo’
* removing ‘/N/home/j/f/jfreimer/Mason/R/lib64/R/library/Cairo’
Anaconda has an R package of cairo (https://anaconda.org/r/r-cairo) so all of the dependencies that I need should be installable via conda. However, I am trying to use the standalone R that I installed and not conda R as I have had trouble with other packages in conda R. I was wondering if anyone has any suggestions
try:
R -e "install.packages('cairo')" --configure-vars=
"CAIRO_CFLAGS=/PATH_TO_CAIRO/include/cairo;
CAIRO_LIBS=/PATH_TO_CAIRO/lib/cairo"
This work for me.
I had similar issues. I solved it by simply uninstalling and re-installing.
Open up R in the terminal console:
R
Uninstall Cairo
remove.packages("Cairo")
Re-install:
install.packages("Cairo")

gcc error when installing Statnet package

Installing statnet on mac 10.10.3 with R 3.2.x (RStudio 0.99.441).
ld: warning: directory not found for option '-L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [latentnet.so] Error 1
ERROR: compilation failed for package ‘latentnet’
* removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/latentnet’
Warning in install.packages :
installation of package ‘latentnet’ had non-zero exit status
ERROR: dependency ‘latentnet’ is not available for package ‘statnet’
* removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/statnet’
Warning in install.packages :
installation of package ‘statnet’ had non-zero exit status
I tried updating XCode/Command Line Tools. Also tried not installing dependencies. I have been able to install other packages, such as ergm and sna.
It looks like the install is looking for the GCC folder and not finding it.
whereis gcc
reveals that my gcc is in /usr/bin/gcc
It looks like the install is looking for it in /usr/local/lib/gcc/
Is there a way to fix this?
This is a compilation error that you only get if you are trying to install packages from source, or when a package requires a library to be compiled from source. Normally, if you don’t use the latest version of R, you can install statnet from binary and thus R won’t have to compile the source package.
The version you are mentioning at the beginning of your message (0.99.441) is the version of your R-Studio, and not R. The version of your R is 3.2.x (Hence its address in the Library folder: /Library/Frameworks/R.framework/Versions/3.2/Resources…). Before trying to fix the compilation error you may want to try to roll back your R to a version like 3.1.2 or 3.1.3 on which you can probably download and install statnet in binary format.
For the compiler, my guess is that even if you fix the address of your gcc with a symlink, you will still get an error about gfortran or the version of gcc. Once I solved this issue by installing R and the right version of gcc through Homebrew, but right now I don’t have the possibility to try the solution and tell you exactly how.
My experience (on Yosemite) is that if you use 3.1.2 or 3.1.3, even if there is need for compilation, the error with gcc won’t occur.
sudo mkdir /usr/bin/lib && sudo ln -s /usr/bin/gcc /usr/bin/lib/gcc
Creates a new directory in /usr/bin called `lib' and creates a symbolic link to gcc in that new directory.
If that doesn't fix the error, you can undo it with:
sudo rm -i /usr/bin/lib/gcc && sudo rm -id /usr/bin/lib

Resources