64

I just wasted the whole day trying to figure out how to install the udunits2 package to be able to install the units package to be able to install the ggforce and ggraph packages.

I'm trying to install it on Ubuntu 16.04, and R >= 3.3 since ggforce was built under R 3.3.

I followed these instructions here: https://github.com/edzer/units/issues/1

Although I have libudunits-2.0 and udunits installed on my machine (as sudo apt-get install udunits2 doesn't find a udunits2 package), and the PATH to the libudunits-2 and udunits locations on my $PATH, in R when I try installing udunits2, units or ggforce I'm getting an error that says,

--* installing *source* package ‘udunits2’ ...
** package ‘udunits2’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
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... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for XML_ParserCreate in -lexpat... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking udunits2.h usability... no
checking udunits2.h presence... no
checking for udunits2.h... no
checking for ut_read_xml in -ludunits2... no
-----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.
     ERROR: configuration failed for package ‘udunits2’
* removing ‘/home/fjay/R/x86_64-pc-linux-gnu-library/3.3/udunits2’
* restoring previous ‘/home/fjay/R/x86_64-pc-linux-gnu-library 
/3.3/udunits2’

The downloaded source packages are in
    ‘/tmp/Rtmp0syxnJ/downloaded_packages’
Warning message:
In install.packages("udunits2", lib = "/home/fjay/R/x86_64-pc-linux-
 gnu-library/3.3") :
 installation of package ‘udunits2’ had non-zero exit status
>

So, umm, it's looking for the udunits2.h and libudunits2.a files.... So, I downloaded udunits2 from CRAN, unpacked it and put it in my R library. Then, if I put library(udunits2, lib.loc = "my library dir") I get an error saying it's not installed. So, when I install.package('udunits2', repo = NULL, libconfig.args = '--with-udunits2-lib=/home/fjay/R/x86_64-pc-linux-gnu-library/3.3') or install.packages('units',....) or install.packages('ggforce',...) it is still looking for these files...and, after inspection of the udunits2 package these files are not in any of the udunits2 folders.

If anyone knows how to install this udunits2 packages please help me!

3 Answers 3

Reset to default

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

114

I had the same problem. Following the first answer from here you have to install -dev version of udunits:

sudo apt-get install libudunits2-dev

Then the installation of udunits2 and ggforce goes without any error.

EDIT:

Following the comments below, for CentOS7 it should be:

sudo yum install udunits2-devel

And for MacOS:

brew install udunits
7
  • 6
    On CentOS7, it should be sudo yum install udunits2-devel.
    – Phil
    Sep 27, 2017 at 21:23
  • 1
    yum install udunits2-devel says No package found. How can i resolve this?
    – minion
    Apr 16, 2018 at 9:14
  • Perfect. Then install.packages("udunits2", configure.args = '--with-udunits2-include=/usr/include/udunits2') in R worked well. Apr 20, 2018 at 19:25
  • 2
    On Mac OS X I just had to do brew install udunits
    – vpipkt
    May 11, 2018 at 13:13
  • just FYI, for anyone who might be encountering this issue via the current, container-based, sudo = FALSE Travis CI default, instead declare addons: apt: packages: - libudunits2-dev in your .travis.yml.
    – maxheld
    Sep 14, 2018 at 12:45
9

I have installed the udunits2 package in R on the Linux platform (redhat) without Internet connnection.

I also had this problem.

Firstly, I installed the udunits2 (not the R package udunits2)in the Linux example at (/usr/include/udunits2).

Secondly, running this command worked: install.packages("udunits2_0.13.tar.gz",configure.args='--with-udunits2-include=/usr/include/udunits2')

I hope this experience could help you.

1
  • 3
    The second command should probably read install.packages("udunits2",configure.args='--with-udunits2-include=/usr/include/udunits2') without udunits version (udunits2_0.13.tar.gz not available for the latest version of R). This worked for me on Fedora 26.
    – giocomai
    Sep 23, 2017 at 13:31
7

This won't be any help to the chap that asked the question, but I was just having the same issue on a computing cluster without root access and the following worked:

homedir <- Sys.getenv("HOME")
udunits_dir <- file.path(Sys.getenv("HOME"), "udunits")
system(paste0("mkdir ", udunits_dir))
system(paste0("wget --directory-prefix=", udunits_dir, " ftp://ftp.unidata.ucar.edu/pub/udunits/udunits-2.2.25.tar.gz"))
owd <- getwd()
setwd(udunits_dir)
system("tar xzvf udunits-2.2.25.tar.gz")
setwd(file.path(udunits_dir, "udunits-2.2.25"))
system(paste0("./configure --prefix=", udunits_dir, "/local"))
system("make")
system("make install")
setwd(owd)
Sys.setenv(LD_LIBRARY_PATH=paste0(Sys.getenv("LD_LIBRARY_PATH"), ":", udunits_dir, "/local/lib"))
install.packages("udunits2", 
                 type = "source",
                 configure.args = c(paste0("--with-udunits2-include=", udunits_dir, "/local/include"), 
                                    paste0("--with-udunits2-lib=", udunits_dir, "/local/lib")),
                 repos = "http://cran.rstudio.com")
dyn.load(paste0(udunits_dir, "/local/lib/libudunits2.so.0"))
install.packages("units", repos = "http://cran.rstudio.com",
             configure.args = c(paste0("--with-udunits2-include=", udunits_dir, "/local/include"), 
                                paste0("--with-udunits2-lib=", udunits_dir, "/local/lib")))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.