Install R cairo package after installing cairo via conda - r

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")

Related

conda build R package fails due to C compiler

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

Clang issues when installing the igraph R package on Mac OS

I'm trying to install the pagoda2 R package on my Mac.
Did the:
brew update
brew install cmake boost eigen gsl curl openssl wget
requirements.
Then downloaded and installed the clang4-r.pkg package.
Then installed gfortran for Mac.
And then in the inside R part, in the:
install_github("igraph/rigraph")
it fails with this error:
* installing *source* package ‘igraph’ ...
checking for gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/private/var/folders/t1/t8mvpqx15t50z60z7nqt18y40000gn/T/RtmpNhyp5H/devtools65d816247573/igraph-rigraph-057cc9d':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
ERROR: configuration failed for package ‘igraph’
I tried editing my .R/Makevars file to the following:
# The following statements are required to use the clang4 binary
LDFLAGS=-L/usr/local/opt/gettext/lib -L/usr/local/opt/llvm/lib
CPPFLAGS=-I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include
#CC=/usr/local/clang4/bin/clang
CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
#CXX=/usr/local/clang4/bin/clang++
CXX=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
#CXX1X=/usr/local/clang4/bin/clang++
CXX1X=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
#CXX98=/usr/local/clang4/bin/clang++
CXX98=/usr/local/clang4/bin/clang
#CXX11=/usr/local/clang4/bin/clang++
CXX11=/usr/local/clang4/bin/clang
#CXX14=/usr/local/clang4/bin/clang++
CXX14=/usr/local/clang4/bin/clang
#CXX98=/usr/local/clang4/bin/clang
CXX98=/usr/local/clang4/bin/clang
#LDFLAGS=-L/usr/local/clang4/lib
# End clang4 inclusion statements
But still same error message.
Any idea?

Problem with R package installation: sf; system library not found

I am trying to install the R package sf. It mentions the system dependencies GDAL, GEOS and PROJ.4. I have installed all of these using
$sudo apt-get install libgdal-dev libgeos-dev libproj-dev proj-bin
However sf still complains that it is missing (something from?) the libraries:
$sudo R CMD INSTALL sf_0.6-3.tar.gz
[...]
configure: pkg-config proj exists, will use it
checking proj_api.h usability... yes
checking proj_api.h presence... yes
checking for proj_api.h... yes
configure: PROJ: 4.9.2
checking for pj_init_plus in -lproj... no
configure: error: libproj not found in standard or given locations.
ERROR: configuration failed for package ‘sf’
The same goes for using the install.packages("sf") command in R. I am using R version 3.5.0 on an Ubuntu 16.04 system, I managed to install the package on another computer with R version 3.4.3 but don't know what I did different to make it work then. Both apt and pkg-config --modversion proj say that the version is higher than needed (4.9.2) and i tried to find some info that could help me resolve the problem using pkg-config or on the internet but couldn't find anything. I did find the following line in /usr/include/proj_api.h (found using sudo apt-file search proj_api.h):
projPJ pj_init_plus(const char *);
which mentions the thing in the check not found, but I don't understand in what way it relates to this.
As a note, I do have two versions of R installed, I also have version 3.2.3 on the computer. Could this be a source of the problem? (I am sure, that the version I am installing the sf package to is 3.5)
EDIT
I have found another R package (proj4) with the libproj dependency and tried to install that one. While it did stop at the same error, this one gave a longer message:
>install.packages("proj4")
[...]
checking proj_api.h usability... yes
checking proj_api.h presence... yes
checking for proj_api.h... yes
checking for pj_init_plus in -lproj... no
configure: error: libproj and/or proj_api.h not found in standard search locations.
*** Install PROJ.4 and if necessary set PKG_CPPFLAGS/PKG_LIBS accordingly.
ERROR: configuration failed for package ‘proj4’
The PKG_CPPFLAGS/PKG_LIBS variables? are not found in R, and echo $PKG_LIBS showed nothing either. Might there be a way I could set these so that the packages can be installed?
I am thankful for any tips or hints as to what causes this.
Peter
I think you may be using older versions of libgdal-dev and you
the following question could be the issue you are seeing
Rgdal installation failed on ubuntu 16.04
sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
sudo apt update
sudo apt install gdal-bin python-gdal python3-gdal libgdal1-dev

R Cairo package installation failed in Ubuntu 18.04

I attempt to install Cairo package in R under a Docker Ubuntu 18.04 container. Before installing the R Cairo package, I installed these packets in Ubuntu: libgtk2.0-dev, libcairo2-dev, xvfb, xauth, xfonts-base, r-base-dev, and libxt-dev.
However, when I installed Cairo package in R, I got the following error:
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=-lfreetype -lz -lpng16 -lz -lcairo -lXext -lXrender -lX11
checking for library containing deflate... no
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 ‘/opt/conda/lib/R/library/Cairo’
The downloaded source packages are in
‘/tmp/RtmprETcPh/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("Cairo") :
installation of package ‘Cairo’ had non-zero exit status
I've checked /tmp/RtmprETcPh/downloaded_packages, and there is only a filed called Cairo_1.5-9.tar.gz. And I don't know where to find config.log for more compile details of compiling a simple Cairo program.
Please help me to resolve out this issue if anybody know how to resolve out this issue.
Thank you
You may need to install the x11 dev libs since the docker container is likely not running these.
Try
sudo apt-get install libx11-dev
Under ubuntu 20.04, after installing libx11-dev, trying to install Cairo gave the error X11/Intrinsic.h not found. This is in libxt-dev. After installing this, Cairo could be installed.

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)

Resources