I'm working in an Amazon-Linux-2 environment and would like to install the R-package "sf" which depends on the libudunits2-dev system library. I get the error message:
Configuration failed because libudunits2.so was not found. Try installing:
* deb: libudunits2-dev (Debian, Ubuntu, ...)
* rpm: udunits2-devel (Fedora, EPEL, ...)
* brew: udunits (OSX)
If udunits2 is already installed in a non-standard location, use:
--configure-args='--with-udunits2-lib=/usr/local/lib'
if the library was not found, and/or:
--configure-args='--with-udunits2-include=/usr/include/udunits2'
if the header was not found, replacing paths with appropriate values.
You can alternatively set UDUNITS2_INCLUDE and UDUNITS2_LIBS manually.
udunits2 cannot be installed with sudo yum install libudunits2-dev or libunits2-devel. I attempted installing and using epel but that also does not contain this library.
I installed udunits2 from source, and it can find the library but there is still an error. I am unsure how to build a dev version of this library
wget ftp://ftp.unidata.ucar.edu/pub/udunits/udunits-2.2.28.tar.gz &&\
tar -xvzf udunits-2.2.28.tar.gz; rm udunits-2.2.28.tar.gz &&\
cd udunits-2.2.28 &&\
./configure -prefix=/usr/local &&\
make install &&\
cd .. && rm -rf udunits-2.2.28
Current error message:
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for 'units' in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/usr/lib64/R/library/00LOCK-units/00new/units/libs/units.so':
libudunits2.so.0: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing '/usr/lib64/R/library/units'
ERROR: dependency 'units' is not available for package 'sf'
Edit ---------------------------
Thanks Knud Larsen for correcting the epel-package name. It looks like the installation is a bit involved but here is what I've figured out.
The sf package dependencies are libudunits2-dev libgdal-dev libgeos-dev libproj-dev. Which for amazon-linux-2 needs epel and to built from source. (note: epel gdal is version 1 and not compatible).
# Add epel repository
sudo amazon-linux-extras install epel
# install udunits2
yum install -y udunits2-devel
# install proj/gdal dependency
yum install -y gcc-c++ cpp sqlite-devel libtiff cmake3
# build/install proj
wget https://download.osgeo.org/proj/proj-6.1.1.tar.gz
tar -xvf proj-6.1.1.tar.gz
cd proj-6.1.1
./configure
sudo make
sudo make install
cd ..
rm -rf proj-6.1.1*
# build/install gdal
wget https://github.com/OSGeo/gdal/releases/download/v3.2.1/gdal-3.2.1.tar.gz
tar -xvf gdal-3.2.1.tar.gz
cd gdal-3.2.1
./configure --with-proj=/usr/local --with-python
sudo make
sudo make install
cd ..
rm -rf gdal-3.2.1*
Related
** UPDATED QUESTION **
I am running an R Studio server docker container and when login cannot import libraries (e.g. rvest) I installed in R studio with all dependecies installed.
docker-compose.yml
version: '3.9'
services:
rstudio:
build: ./docker/rstudio
container_name: etl
environment:
- PASSWORD=yourpassword
ports:
- 8787:8787
Dockerfile
FROM rocker/rstudio
RUN apt-get clean all && \
apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
python3-pip \
&& apt-get clean all && \
apt-get purge && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN /usr/local/lib/R/bin/R -e 'install.packages("ODBC", repos="https://packagemanager.rstudio.com/cran/__linux__/focal/latest")' && \
/usr/local/lib/R/bin/R -e 'install.packages("RODBC", repos="https://packagemanager.rstudio.com/cran/__linux__/focal/latest")' && \
/usr/local/lib/R/bin/R -e 'install.packages("DBI", repos="https://packagemanager.rstudio.com/cran/__linux__/focal/latest")' && \
/usr/local/lib/R/bin/R -e 'install.packages("rvest", repos="https://packagemanager.rstudio.com/cran/__linux__/focal/latest")'
Error
> library(rvest)
Error: package or namespace load failed for ‘rvest’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/usr/local/lib/R/site-library/xml2/libs/xml2.so':
libxml2.so.2: cannot open shared object file: No such file or directory
The file '/usr/local/lib/R/site-library/xml2/libs/xml2.so' actually exists, but #2 not : '/usr/local/lib/R/site-library/xml2/libs/xml2.so.2'
The first error message is key:
unable to load shared object '/usr/local/lib/R/site-library/xml2/libs/xml2.so
These RSPM packages do not install system dependencies (as they can't, they are simple tar.gz archives; the site offers some help). You could either just nstall the pre-made binaries from Ubuntu (r-cran-{odbc,rodbc,dbi,rvest}) or take care of the system-dependencies via eg
apt install libxml2 libodbc1
taking care of the XML and ODBC libraries.
Edit: In response to your edited question look at this search for file libxml2.so.2 at packages.ubuntu.com pointing you to Ubuntu package libxml2. Which is exactly what I wrote earlier: you need sudo apt install libxml2 because the CRAN (source) package does not do it for you (and cannot). See r2u for an alternative.
Renv, can't install devtools
Goal: install devtools with renv
Expected Results: Installation of devtools.
Actual Results: see error below
I try to install packages in RStudio through renv (On Ubuntu), to use for my own package. I performed Renv init(), packages will install except for devtools. When I try to install devtools through renv::install()I get the following error:
> renv::install("devtools")
Retrieving 'https://cran.rstudio.com/src/contrib/devtools_2.4.4.tar.gz' ...
OK [file is up to date]
Retrieving 'https://cran.rstudio.com/src/contrib/pkgdown_2.0.6.tar.gz' ...
OK [file is up to date]
Retrieving 'https://cran.rstudio.com/src/contrib/ragg_1.2.2.tar.gz' ...
OK [file is up to date]
Installing ragg [1.2.2] ...
FAILED
Error installing package 'ragg':
================================
* installing *source* package ‘ragg’ ...
** package ‘ragg’ successfully unpacked and MD5 sums checked
** using staged installation
Package libtiff-4 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libtiff-4.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libtiff-4' found
Package libtiff-4 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libtiff-4.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libtiff-4' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lfreetype -lpng16 -ltiff -lz -ljpeg -lbz2
-----------------------------[ ANTICONF ]-------------------------------
Configuration failed to find one of freetype2 libpng libtiff-4. Try installing:
* deb: libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev (Debian, Ubuntu, etc)
* rpm: freetype-devel libpng-devel libtiff-devel libjpeg-turbo-devel (Fedora, CentOS, RHEL)
* csw: libfreetype_dev libpng16_dev libtiff_dev libjpeg_dev (Solaris)
If freetype2 libpng libtiff-4 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a freetype2 libpng libtiff-4.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
-------------------------- [ERROR MESSAGE] ---------------------------
<stdin>:1:22: fatal error: ft2build.h: No such file or directory
compilation terminated.
--------------------------------------------------------------------
ERROR: configuration failed for package ‘ragg’
* removing ‘/home/SmitsG/Documents/Projects/{"package_location"}/renv/staging/1/ragg’
Error: install of package 'ragg' failed [error code 1]
So this resulted in the following errors:
No package 'libtiff-4' found
:1:22: fatal error: ft2build.h: No such file or directory
Error: install of package 'ragg' failed [error code 1]
I tried the following:
Installation in other package environment. This didn't work out
https://techoverflow.net/2019/06/11/how-to-fix-ft2build-h-no-such-file-or-directory/
Seems that I am missing the ft2build.h header file from
libfreetype. So I tried to install libfreetype from tar.gz and from
CRAN, for renv (this didn't install automatically). This didn't work out.
Package libtiff-4 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libtiff-4.pc'
to the PKG_CONFIG_PATH environment variable
I found this link: https://github.com/numworks/epsilon/issues/592 where the set the PKG_CONFIG_PATH. But I think this can only be done when libfreetype is installed through renv.
{:~/path_to_package}$ pkg-config --cflags freetype2-I/usr/include/freetype2
-I/usr/include/libpng16
{:~/path_to_package}$ pkg-config --libs --cflags libtiff-4Package libtiff-4 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libtiff-4.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libtiff-4' found
I am a newbie to linux and I have found that installing R packages can be very frustrating because (1) there are numerous linux dependencies that need to be installed first and (2) it takes forever. Below is a script that installs the dependencies that I have found in installing R on my system (Linux Mint 21 Vanessa).
sudo apt update
sudo apt install -q \
cargo \
cmake \
default-jdk \
fonts-roboto \
htop \
libcairo2-dev \
libclang-dev \
libcurl4-openssl-dev \
libfontconfig1-dev \
libfreetype6-dev \
libfribidi-dev \
libgdal-dev \
libgeos-dev \
libharfbuzz-dev \
libjpeg-dev \
libproj-dev \
libpng-dev \
libpq-dev \
libsodium-dev \
libssl-dev \
libtiff5-dev \
libudunits2-dev \
libx11-dev \
libxml2-dev \
openjdk-8-jdk \
openjdk-8-jre \
pandoc \
ttf-mscorefonts-installer \
xorg-dev
I am using a continuumio/miniconda3:latest base container and activating a Conda environment.
This all works fine.
When I run:
RUN R -e "install.packages('devtools',repos = 'http://cran.us.r-project.org')"
I get an error:
configure: Package dependency requirement 'libgit2 >= 0.26.0' could not be satisfied.
-----------------------------------------------------------------------
Unable to find the libgit2 library on this system. Building 'git2r'
using the bundled source of the libgit2 library.
To build git2r with a system installation of libgit2, please install:
libgit2-dev (package on e.g. Debian and Ubuntu)
libgit2-devel (package on e.g. Fedora, CentOS and RHEL)
libgit2 (Homebrew package on OS X)
and try again.
If the libgit2 library is installed on your system but the git2r
configuration is unable to find it, you can specify the include and
lib path to libgit2 with:
given you downloaded a tar-gz archive:
R CMD INSTALL git2r-.tar.gz --configure-vars='INCLUDE_DIR=/path/to/include LIB_DIR=/path/to/lib'
or cloned the GitHub git2r repository into a directory:
R CMD INSTALL git2r/ --configure-vars='INCLUDE_DIR=/path/to/include LIB_DIR=/path/to/lib'
or download and install git2r in R using
install.packages('git2r', type='source', configure.vars='LIB_DIR=-L/path/to/libs INCLUDE_DIR=-I/path/to/headers')
On macOS, another possibility is to let the configuration
automatically download the libgit2 library from the Homebrew
package manager with:
R CMD INSTALL git2r-.tar.gz --configure-vars='autobrew=yes'
or
R CMD INSTALL git2r/ --configure-vars='autobrew=yes'
or
install.packages('git2r', type='source', configure.vars='autobrew=yes')
-----------------------------------------------------------------------
configure: Attempting configuration of bundled libgit2
checking size of void*... 8
checking for library containing inflate... no
configure: error: in `/tmp/Rtmpbkmfhr/R.INSTALL8c407eb001/git2r':
configure: error:
---------------------------------------------
The zlib library that is required to build
git2r was not found.
Please install:
zlib1g-dev (package on e.g. Debian and Ubuntu)
zlib-devel (package on e.g. Fedora, CentOS and RHEL)
and try again.
If the zlib library is installed on your
system but the git2r configuration is
unable to find it, you can specify the
include and lib path to zlib with:
R CMD INSTALL git2r --configure-vars='LIBS=-L/path/to/libs CPPFLAGS=-I/path/to/headers'
---------------------------------------------
See `config.log' for more details
ERROR: configuration failed for package ‘git2r’
* removing ‘/opt/conda/envs/r-app/lib/R/library/git2r’
I have libgit2-dev installed at the start of my Dockerfile using apt-get install libgit2-dev and it installs libgit2 version 0.27.7.
Now the odd part about this is if I start the container and access it, I can run the "install.packages('devtools',repos = 'http://cran.us.r-project.org')" just fine and it works.
Dockerfile:
FROM continuumio/miniconda3:latest
RUN apt-get update -y; apt-get upgrade -y; \
apt-get install -y vim ssh libgit2-dev zlib1g-dev \
build-essential gcc gfortran g++
RUN conda update -n base -c defaults conda
COPY environment.yml environment.yml
RUN conda env create -f environment.yml
RUN echo "source activate r-env" >> ~/.bashrc
ENV PATH /opt/conda/envs/r-env/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN R -e "install.packages('devtools',repos = 'http://cran.us.r-project.org')"
environment.yml:
name: r-env
channels:
- conda-forge
- defaults
dependencies:
- python=3.7
- r-essentials
- r-base
Replace the last line of your Dockerfile with:
RUN Rscript -e "install.packages('devtools',repos = 'http://cran.us.r-project.org')"
I am trying to install "choroplethr."
I have read the following related-looking errors:
https://askubuntu.com/questions/1057100/error-libudunits2-a-not-found-when-installing-ggraph-additional-error-objec
Install udunits2 package for R3.3
Their recommendation is to install something I have already installed. I have libudunits2 installed in a standard location, with:
$ sudo apt-get install libudunits2-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libudunits2-dev is already the newest version (2.2.26-1).
I can see headers:
$ ll /usr/include/ | grep unit
-rw-r--r-- 1 root root 39998 Jan 5 2018 udunits2.h
-rw-r--r-- 1 root root 5195 Jan 5 2018 udunits.h
However, on installation, I get this error:
$ R
R version 3.5.1 (2018-07-02) -- "Feather Spray"
> install.package("choroplethr", dep=T)
...
configure: error: in `/tmp/RtmpWC06JV/R.INSTALL7cbb4928db67/units':
configure: error:
--------------------------------------------------------------------------------
Configuration failed because libudunits2.so was not found. Try installing:
* deb: libudunits2-dev (Debian, Ubuntu, ...)
* rpm: udunits2-devel (Fedora, EPEL, ...)
* brew: udunits (OSX)
If udunits2 is already installed in a non-standard location, use:
--configure-args='--with-udunits2-lib=/usr/local/lib'
if the library was not found, and/or:
--configure-args='--with-udunits2-include=/usr/include/udunits2'
if the header was not found, replacing paths with appropriate values.
You can alternatively set UDUNITS2_INCLUDE and UDUNITS2_LIBS manually.
--------------------------------------------------------------------------------
I've done these settings, but
install.packages("udunits2", configure.args = '--with-udunits2-include=/usr/include/udunits2')
-----Error: libudunits2.a not found-----
If the udunits2 library is installed in a non-standard location,
use --configure-args='--with-udunits2-lib=/usr/local/lib' for example,
or --configure-args='--with-udunits2-include=/usr/include/udunits2'
replacing paths with appropriate values for your installation.
You can alternatively use the UDUNITS2_INCLUDE and UDUNITS2_LIB
environment variables.
If udunits2 is not installed, please install it.
It is required for this package.
What am I missing? Is this package OSX only?
For Ubuntu with R 3.5 you can use the c2d4u3.5 PPA made available by the same persons that bring you R Ubuntu packages on CRAN, c.f. https://cran.r-project.org/bin/linux/ubuntu/README.html and http://dirk.eddelbuettel.com/blog/2017/12/22/:
sudo add-apt-repository ppa:marutter/c2d4u3.5
sudo apt-get update
After that you can install binary packages for most CRAN packages:
sudo apt-get install r-cran-choroplethr
This should work for all packages that are mentioned in CRAN task views.
Besides this, I tried to reproduce your installation problems using docker:
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install --yes --no-install-recommends gnupg ca-certificates \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 \
&& echo "deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/" >> /etc/apt/sources.list \
&& apt-get update \
&& apt-get install --yes --no-install-recommends r-base-dev libudunits2-dev \
&& Rscript -e 'install.packages(c("units", "udunits2"))'
However, the image was build without problems.
I have been trying to install rgdal from RStudio Version 1.0.44 on ubuntu 16.04 then I was getting the gdal-config not found error. I resolved this by installing the libgdal1-dev & libproj packages but now i'm getting the following error. Someone help me resolve this.
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/hetch/R/x86_64-pc-linux-gnu-library/3.3/rgdal/libs/rgdal.so':
/usr/lib/x86_64-linux-gnu/libgeos_c.so.1: undefined symbol:_ZN4geos4geom18IntersectionMatrixC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/hetch/R/x86_64-pc-linux-gnu-library/3.3/rgdal’
Warning in install.packages :
installation of package ‘rgdal’ had non-zero exit status
I have had some issues trying to install rgdal package but finally I succeeded.
My problem was that gdal > 2.0 is needed, and it does not ship with ubuntu 16.04 by default, so extra packages are needed.
I ended up installing the following packages:
sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
sudo apt update
sudo apt install gdal-bin python-gdal python3-gdal libgdal1-dev
Additionally, r > 3.3 is needed too, so I ended up updating ubuntu's default r-base installation like this:
sudo add-apt-repository 'deb https://cran.rediris.es/bin/linux/ubuntu xenial/'
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
sudo apt update
Hope it works for you too.
For Rh6, you have just to install:
yum install proj-devel-4.8.0-4.1.x86_64.rpm
N.B: in my case, my server is not connected to internet, So I download the package from repo to my local machine and then I copied it to my server.