pacificclimate / Rudunits2

GNU General Public License v2.0
26 stars 10 forks source link

/usr/include/udunits2 is not found automatically or through Environment variable #25

Open cderv opened 6 years ago

cderv commented 6 years ago

This is related to #14 , that should have been fixed by #19.

I can't install the package if udunits2 is not inside the /usr/include directory. The header file is in /usr/include/udunits that thanks to #19, it should be searched in. However, install.packages("udunits2") fails with this error

checking udunits2.h usability... no
checking udunits2.h presence... no
checking for udunits2.h... no
checking for ut_read_xml in -ludunits2... yes
-----Error: udunits2.h 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.

It works if I use install.packages("udunits2",configure.args='--with-udunits2-include=/usr/include/udunits2/') but it does not work if I use environment variable UDUNITS2_INCLUDE

export UDUNITS2_INCLUDE=/usr/include/udunits2
Rscript -e 'install.packages("udunits")'

I have tried few ways to configure environment variable, and I can't make it to work. Also, /usr/include/udunits2 should have searched https://github.com/pacificclimate/Rudunits2/blob/282e73289f0df23ae80e1dcb03a881c2be74725e/configure.ac#L13-L23

Is this working for someone ? Should I dig deeper on what is going on ?

Thank you for your advice.

For the context, I need to work with environment variable for a use case with packrat that cannot handle option configure.args='--with-udunits2-include=/usr/include/udunits2/'

HenrikBengtsson commented 4 years ago

I'm confirming that UDUNITS2_INCLUDE does not work - the configure script fail to locate the files in:

export UDUNITS2_INCLUDE=/usr/include/udunits2 
ls -l "$UDUNITS2_INCLUDE"
total 76
drwxr-xr-x.   2 root root    60 Jan 31  2019 .
drwxr-xr-x. 114 root root 16384 Mar 27 04:17 ..
-rw-r--r--.   1 root root  5895 Dec  8  2015 converter.h
-rw-r--r--.   1 root root 39992 Dec  8  2015 udunits2.h
-rw-r--r--.   1 root root  5195 Dec  8  2015 udunits.h

This is a show stopper for large-scale software stack installation on CentOS.

pat-s commented 4 years ago

The same applies on macOS when setting UDUNITS2_INCLUDE=/usr/local/Cellar/udunits/2.2.27.6/include.

HenrikBengtsson commented 4 years ago

@jameshiebert, is there any chance you could get this fixed (I see there are PRs addressing this) and roll out a new version on CRAN? It would be of great value to the community and lots of sysadms out there. Many people struggle and spend lots of time trying to figure this out and those hours add up quickly. The strong dependency comes in from the sf package via units.

pat-s commented 4 years ago

Apparently there is a typo in the env var name which the package shows during installation error. One needs to append an "S", so "UDUNITS2_LIBS" instead of "UDUNITS2_LIB".

In addition, if you are on macOS 10.15 you might need to append -I/usr/local/include to your CPPFLAGS var in ~/.R/Makevars. This helps {udunits2} find the "include" dir automatically.

I put some time in to compare the Makevars files of the {units} package with the one of {udunits2} and did some tests but was not successful in getting it auto-linked.

I've found no other way than specifying the env var so that linking works.

This package has not seen an update since 2016 - it might be a time fix some things up. The package will most likely never error on CRAN because it has no tests. Maybe {units} has some options to drop it and include the binding to udunits2 in some other way.

install.packages("udunits2", type = "source")
#> Installing package into '/Users/pjs/Library/R/4.0/library'
#> (as 'lib' is unspecified)
#> Warning in install.packages("udunits2", type = "source"): installation of
#> package 'udunits2' had non-zero exit status

# works
Sys.setenv("UDUNITS2_LIBS" = "/usr/local/lib")
install.packages("udunits2", type = "source")
#> Installing package into '/Users/pjs/Library/R/4.0/library'
#> (as 'lib' is unspecified)

Created on 2020-04-15 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.0.0 beta (2020-04-14 r78227) #> os macOS Catalina 10.15.4 #> system x86_64, darwin17.0 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Berlin #> date 2020-04-15 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.0) #> backports 1.1.6 2020-04-05 [1] CRAN (R 4.0.0) #> callr 3.4.3 2020-03-28 [1] CRAN (R 4.0.0) #> cli 2.0.2 2020-02-28 [1] CRAN (R 4.0.0) #> crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.0) #> desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.0) #> devtools 2.3.0 2020-04-10 [1] CRAN (R 4.0.0) #> digest 0.6.25 2020-02-23 [1] CRAN (R 4.0.0) #> ellipsis 0.3.0 2019-09-20 [1] CRAN (R 4.0.0) #> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.0) #> fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.0) #> fs 1.4.1 2020-04-04 [1] CRAN (R 4.0.0) #> glue 1.4.0 2020-04-03 [1] CRAN (R 4.0.0) #> highr 0.8 2019-03-20 [1] CRAN (R 4.0.0) #> htmltools 0.4.0 2019-10-04 [1] CRAN (R 4.0.0) #> knitr 1.28 2020-02-06 [1] CRAN (R 4.0.0) #> magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.0) #> memoise 1.1.0 2017-04-21 [1] CRAN (R 4.0.0) #> pkgbuild 1.0.6 2019-10-09 [1] CRAN (R 4.0.0) #> pkgload 1.0.2 2018-10-29 [1] CRAN (R 4.0.0) #> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.0) #> processx 3.4.2 2020-02-09 [1] CRAN (R 4.0.0) #> ps 1.3.2 2020-02-13 [1] CRAN (R 4.0.0) #> R6 2.4.1 2019-11-12 [1] CRAN (R 4.0.0) #> Rcpp 1.0.4.6 2020-04-09 [1] CRAN (R 4.0.0) #> remotes 2.1.1 2020-02-15 [1] CRAN (R 4.0.0) #> rlang 0.4.5 2020-03-01 [1] CRAN (R 4.0.0) #> rmarkdown 2.1 2020-01-20 [1] CRAN (R 4.0.0) #> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 4.0.0) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.0) #> stringi 1.4.6 2020-02-17 [1] CRAN (R 4.0.0) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.0) #> testthat 2.3.2 2020-03-02 [1] CRAN (R 4.0.0) #> usethis 1.6.0.9000 2020-04-14 [1] local #> withr 2.1.2 2018-03-15 [1] CRAN (R 4.0.0) #> xfun 0.13 2020-04-13 [1] CRAN (R 4.0.0) #> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.0) #> #> [1] /Users/pjs/Library/R/4.0/library #> [2] /Library/Frameworks/R.framework/Versions/4.0/Resources/library ```
HenrikBengtsson commented 4 years ago

Workaround for CentOS 7 users:

If you have 'libudunits2-devel' installed (*) on your system, then you can install the udunits2 package from CRAN as:

> install.packages("udunits2", configure.args="--with-udunits2-include=/usr/include/udunits2")

(*) To check whether you have the 'libudunits2-devel' library installed on the system, first check that you have the run-time 'libudunits2' library installed as:

$ ldconfig -p | grep libudunits2
    libudunits2.so.0 (libc6,x86-64) => /lib64/libudunits2.so.0
    libudunits2.so (libc6,x86-64) => /lib64/libudunits2.so

Then, check that you have the 'libudunits2-devel' library installed by verifying that you have the include files (which are needed to build and install the R package but not to run it):

$ ls -l /usr/include/udunits2
total 56
-rw-r--r--. 1 root root  5895 Dec  8  2015 converter.h
-rw-r--r--. 1 root root 39992 Dec  8  2015 udunits2.h
-rw-r--r--. 1 root root  5195 Dec  8  2015 udunits.h

The above assumes that the above have been installed as yum install libudunits2-devel by you or the sysadms. If you don't have admin rights, then you have to ask the sysadmin to install that library.

HenrikBengtsson commented 3 years ago

@jameshiebert, any progress on submit the fixed version to CRAN?