Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Troubles installing units (Ubuntu 18.04.1) #223

Closed
MichaelChirico opened this issue Feb 3, 2020 · 17 comments
Closed

Troubles installing units (Ubuntu 18.04.1) #223

MichaelChirico opened this issue Feb 3, 2020 · 17 comments

Comments

@MichaelChirico
Copy link

I've run into & been able to solve this issue many times on a few different systems, but I'm stuck this time. First, from sessionInfo():

R version 3.6.1 (2019-07-05)
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
Running under: Ubuntu 18.04.1 LTS

When running install.packages('units') I get the familiar:

checking for ut_read_xml in -ludunits2... no
configure: error: in `/tmp/RtmpqX0BWE/R.INSTALL18607ec2a7d/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.
--------------------------------------------------------------------------------

See `config.log' for more details

(BTW, I'm not sure where that config.log is written?)

However, I've already successfully installed all the packages as near as I can tell:

sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev libproj-dev

Ran successfully. Now, the possibility is that I'm not includeing the right location during install, which should be covered by the --configure-args part of the helpful message. First, I looked for ut_read_xml in my /usr/include:

grep -r ut_read_xml /usr/include/
/usr/include/udunits2.h:ut_read_xml(
/usr/include/udunits2.h: * the first call to "ut_offset_by_time()". ut_read_xml() calls this function if the
/usr/include/udunits2.h: * Adds a base-unit to a unit-system.  Clients that use ut_read_xml() should not
/usr/include/udunits2.h: * derived-unit radian is a dimensionless-unit.  Clients that use ut_read_xml()

So it seems the header is in the "normal" place; anyway, I tried:

install.packages('units', configure.args = c('--with-udunits2-include=/usr/include/udunits2'))
install.packages('units', configure.args = c('--with-udunits2-include=/usr/include'))

Both to no avail.

To make sure I was pointing to the right place per my sudo apt-get installation, I ran:

dpkg -L libudunits2-dev
/.
/usr
/usr/include
/usr/include/converter.h
/usr/include/udunits.h
/usr/include/udunits2.h
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libudunits2.a
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/udunits.pc
/usr/share
/usr/share/doc
/usr/share/doc/libudunits2-dev
/usr/share/doc/libudunits2-dev/ANNOUNCEMENT
/usr/share/doc/libudunits2-dev/BACKLOG
/usr/share/doc/libudunits2-dev/copyright
/usr/share/doc/libudunits2-dev/udunits2lib.html
/usr/share/doc/libudunits2-dev/udunits2lib.pdf.gz
/usr/share/info
/usr/share/info/udunits2lib.info.gz
/usr/lib/x86_64-linux-gnu/libudunits2.so
/usr/share/doc/libudunits2-dev/changelog.Debian.gz

Noting that libudunits2.so was mentioned by the configure error, I tried to point to this as well:

install.packages('sf', configure.args = '--with-udunits2-lib=/usr/lib/x86_64-linux-gnu/')
install.packages('sf', configure.args = c('--with-udunits2-include=/usr/include/udunits2', '--with-udunits2-lib=/usr/lib/x86_64-linux-gnu/'))
# ... every other combination of
#  --with-udunits2-lib=/usr/lib/x86_64-linux-gnu/{,libunits2.so,libunits2}
#  and
#  --with-udunits2-include=/usr/include{,/udunits2}

All fail the same way. As one last attempt to see if it's related to permissions, I ran:

ls -lah /usr/lib/x86_64-linux-gnu/ | grep units
-rw-r--r-- 1 root root 231K Jan  5  2018 libudunits2.a
lrwxrwxrwx 1 root root   20 Jan  5  2018 libudunits2.so -> libudunits2.so.0.1.0
lrwxrwxrwx 1 root root   20 Jan  5  2018 libudunits2.so.0 -> libudunits2.so.0.1.0
-rw-r--r-- 1 root root 116K Jan  5  2018 libudunits2.so.0.1.0

It seems libudunits2.so is symlinked to a file that has more restricted permissions, but unfortunately I don't have rights to edit this. Is this a red herring? What else can I try to get units installed?

@MichaelChirico
Copy link
Author

MichaelChirico commented Feb 3, 2020

Actually, I've noticed a slight difference in output for this version:

install.packages(
  'units',
  configure.args = c(
    '--with-udunits2-include=/usr/include', 
    '--with-udunits2-lib=/usr/lib/x86_64-linux-gnu'
  )
)

output

configure: units: 0.6-4
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 x86_64-conda_cos6-linux-gnu-c++ -std=gnu++11 accepts -g... yes
checking how to run the C++ preprocessor... x86_64-conda_cos6-linux-gnu-c++ -std=gnu++11 -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 for stdbool.h that conforms to C99... no
checking for _Bool... no
checking for error_at_line... yes
checking for gcc... x86_64-conda_cos6-linux-gnu-cc
checking whether we are using the GNU C compiler... yes
checking whether x86_64-conda_cos6-linux-gnu-cc accepts -g... yes
checking for x86_64-conda_cos6-linux-gnu-cc option to accept ISO C89... none needed
checking for XML_ParserCreate in -lexpat... yes
checking udunits2.h usability... no
checking udunits2.h presence... yes
configure: WARNING: udunits2.h: present but cannot be compiled
configure: WARNING: udunits2.h:     check for missing prerequisite headers?
configure: WARNING: udunits2.h: see the Autoconf documentation
configure: WARNING: udunits2.h:     section "Present But Cannot Be Compiled"
configure: WARNING: udunits2.h: proceeding with the compiler's result
configure: WARNING:     ## -------------------------------------------- ##
configure: WARNING:     ## Report this to edzer.pebesma@uni-muenster.de ##
configure: WARNING:     ## -------------------------------------------- ##
checking for udunits2.h... no
checking udunits2/udunits2.h usability... no
checking udunits2/udunits2.h presence... no
checking for udunits2/udunits2.h... no
checking for ut_read_xml in -ludunits2... yes
configure: error: in `/tmp/RtmplUdnCg/R.INSTALL398a7ede844a/units':
configure: error: 
--------------------------------------------------------------------------------
  Configuration failed because udunits2.h 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.
--------------------------------------------------------------------------------

See `config.log' for more details

@edzer
Copy link
Member

edzer commented Feb 3, 2020

After installing libudunits2-dev with apt-get, you shouldn't use configure.args. If it doesn't work without, there must be something very strange (and very wrong) with your setup.

@Enchufa2
Copy link
Member

Enchufa2 commented Feb 3, 2020

Yeap. I see you are using conda. I'm not familiar with conda, but it must be shadowing the system libraries or doing improper things with the paths, because it works with plain Ubuntu.

@MichaelChirico
Copy link
Author

Ahh, I missed the conda part, thanks. That gives me some ideas. First of which is to delete conda.

Let me play around some more & update in a bit.

@MichaelChirico
Copy link
Author

Thanks so much @Enchufa2 for the extra pair of eyes.

By rights, since I'm using conda-r, I should have run:

conda install r-sf

instead of the install.packages('sf') route. I tried this, but it also failed:

ERROR conda.core.link:_execute(568): An error occurred while installing package 'conda-forge::udunits2-2.2.27.6-h4e0c4b3_1001'.
PermissionError(13, 'Permission denied')
Attempting to roll back.

Rolling back transaction: done

[Errno 13] Permission denied: '/opt/conda/etc/conda/activate.d/udunits2-activate.sh'

However, I don't think there's any issue with units here, but my own setup.

@edzer
Copy link
Member

edzer commented Feb 3, 2020

I have no clue about conda, but if it wants to write in /opt, you may want to run it under sudo.

@MichaelChirico
Copy link
Author

Yep, that would be the next step... sadly I don't have sudo permissions there, so I have to go through the backdoor & rebuild our Dockerfile.

@fedemolina
Copy link

For the record I have the same problem and was because conda.

I did: conda deactivate and then install.packages("units") and works fine.

@mhoban
Copy link

mhoban commented Apr 30, 2021

I ran into this same issue and was able to solve it, so I figured I'd share the solution here. I too was using conda. In my case I have a project using renv to manage packages so I didn't want to install r-units directly. I was able to fix it like this:

First, I installed the udunits2 library using conda:
$ conda install -c conda-forge udunits2

Then, in R, I told renv to find the units includes and libraries inside my miniconda instance:

> config <- c(units="--with-udunits2-lib=/path/to/home/directory/miniconda3/lib --with-udunits2-include=/path/to/home/directory/miniconda3/include")
> options(configure.args=config)
> renv::install("units")

Presumably, you should be able to use install.packages("units", configure.args="<configure args>") the same way. Or alternatively just install r-units using conda if you don't care about renv or whatever.

@Namita-Joshi
Copy link

I am also having problem installing the units package on LInux. My error is

 Warning in install.packages :
  installation of package ‘units’ had non-zero exit status

If there's anyone here that could help me with this, I would really appreciate it

@Enchufa2
Copy link
Member

Enchufa2 commented May 4, 2021

@Namita-Joshi We would need the complete output. Is libudunits2-dev installed in your system?

@Namita-Joshi
Copy link

I don't have the libudunits2-dev installed on my system, which is probably why I can't install 'units' However, I tried installing libudunits2-dev but I got an error. Please see the attached image
Capture

@Enchufa2
Copy link
Member

Enchufa2 commented May 4, 2021

There's something wrong with your installation. Try the suggested commands. You missed sudo in the last one.

@Namita-Joshi
Copy link

That worked! Managed to install the units package. Thank you!

@spfeiffe
Copy link

spfeiffe commented Dec 2, 2022

I'm having a similar issue - I need to install units on an enterprise cloud environment running Ubuntu 18.04. I don't have the highest permissions and am very new to the Linux world:

   2022-12-02T17:16:18.83-0500 [STG/0] OUT R version 4.2.2 (2022-10-31) -- "Innocent and Trusting"
   2022-12-02T17:16:18.83-0500 [STG/0] OUT Copyright (C) 2022 The R Foundation for Statistical Computing
   2022-12-02T17:16:18.83-0500 [STG/0] OUT Platform: x86_64-pc-linux-gnu (64-bit)
   2022-12-02T17:16:18.83-0500 [STG/0] OUT R is free software and comes with ABSOLUTELY NO WARRANTY.
   2022-12-02T17:16:18.83-0500 [STG/0] OUT You are welcome to redistribute it under certain conditions.
   2022-12-02T17:16:18.83-0500 [STG/0] OUT Type 'license()' or 'licence()' for distribution details.
   2022-12-02T17:16:18.83-0500 [STG/0] OUT Natural language support but running in an English locale
   2022-12-02T17:16:18.83-0500 [STG/0] OUT R is a collaborative project with many contributors.
   2022-12-02T17:16:18.83-0500 [STG/0] OUT Type 'contributors()' for more information and
   2022-12-02T17:16:18.83-0500 [STG/0] OUT 'citation()' on how to cite R or R packages in publications.
   2022-12-02T17:16:18.83-0500 [STG/0] OUT Type 'demo()' for some demos, 'help()' for on-line help, or
   2022-12-02T17:16:18.83-0500 [STG/0] OUT 'help.start()' for an HTML browser interface to help.
   2022-12-02T17:16:18.83-0500 [STG/0] OUT Type 'q()' to quit R.
   2022-12-02T17:16:18.94-0500 [STG/0] OUT > install.packages(c("./vendor_r/units_0.8-0.tar.gz"), repos=NULL, dependencies=TRUE, Ncpus=2)
   2022-12-02T17:16:19.38-0500 [STG/0] OUT * installing *source* package ‘units’ ...
   2022-12-02T17:16:19.38-0500 [STG/0] OUT ** package ‘units’ successfully unpacked and MD5 sums checked
   2022-12-02T17:16:19.38-0500 [STG/0] OUT ** using staged installation
   2022-12-02T17:16:19.58-0500 [STG/0] OUT configure: units: 0.8-0
   2022-12-02T17:16:19.85-0500 [STG/0] OUT checking whether the C++ compiler works... yes
   2022-12-02T17:16:19.85-0500 [STG/0] OUT checking for C++ compiler default output file name... a.out
   2022-12-02T17:16:20.24-0500 [STG/0] OUT checking for suffix of executables...
   2022-12-02T17:16:20.32-0500 [STG/0] OUT checking whether we are cross compiling... no
   2022-12-02T17:16:20.35-0500 [STG/0] OUT checking for suffix of object files... o
   2022-12-02T17:16:20.38-0500 [STG/0] OUT checking whether we are using the GNU C++ compiler... yes
   2022-12-02T17:16:20.41-0500 [STG/0] OUT checking whether g++ -std=gnu++14 accepts -g... yes
   2022-12-02T17:16:20.45-0500 [STG/0] OUT checking how to run the C++ preprocessor... g++ -std=gnu++14 -E
   2022-12-02T17:16:20.49-0500 [STG/0] OUT checking for grep that handles long lines and -e... /bin/grep
   2022-12-02T17:16:20.50-0500 [STG/0] OUT checking for egrep... /bin/grep -E
   2022-12-02T17:16:20.68-0500 [STG/0] OUT checking for ANSI C header files... yes
   2022-12-02T17:16:20.73-0500 [STG/0] OUT checking for sys/types.h... yes
   2022-12-02T17:16:20.79-0500 [STG/0] OUT checking for sys/stat.h... yes
   2022-12-02T17:16:20.85-0500 [STG/0] OUT checking for stdlib.h... yes
   2022-12-02T17:16:20.91-0500 [STG/0] OUT checking for string.h... yes
   2022-12-02T17:16:20.98-0500 [STG/0] OUT checking for memory.h... yes
   2022-12-02T17:16:21.04-0500 [STG/0] OUT checking for strings.h... yes
   2022-12-02T17:16:21.10-0500 [STG/0] OUT checking for inttypes.h... yes
   2022-12-02T17:16:21.16-0500 [STG/0] OUT checking for stdint.h... yes
   2022-12-02T17:16:21.23-0500 [STG/0] OUT checking for unistd.h... yes
   2022-12-02T17:16:21.26-0500 [STG/0] OUT checking for stdbool.h that conforms to C99... no
   2022-12-02T17:16:21.32-0500 [STG/0] OUT checking for _Bool... no
   2022-12-02T17:16:21.39-0500 [STG/0] OUT checking for error_at_line... yes
   2022-12-02T17:16:21.39-0500 [STG/0] OUT checking for gcc... gcc
   2022-12-02T17:16:21.45-0500 [STG/0] OUT checking whether we are using the GNU C compiler... yes
   2022-12-02T17:16:21.48-0500 [STG/0] OUT checking whether gcc accepts -g... yes
   2022-12-02T17:16:21.52-0500 [STG/0] OUT checking for gcc option to accept ISO C89... none needed
   2022-12-02T17:16:21.58-0500 [STG/0] OUT checking for XML_ParserCreate in -lexpat... yes
   2022-12-02T17:16:21.63-0500 [STG/0] OUT checking udunits2.h usability... no
   2022-12-02T17:16:21.65-0500 [STG/0] OUT checking udunits2.h presence... no
   2022-12-02T17:16:21.65-0500 [STG/0] OUT checking for udunits2.h... no
   2022-12-02T17:16:21.70-0500 [STG/0] OUT checking udunits2/udunits2.h usability... no
   2022-12-02T17:16:21.72-0500 [STG/0] OUT checking udunits2/udunits2.h presence... no
   2022-12-02T17:16:21.72-0500 [STG/0] OUT checking for udunits2/udunits2.h... no
   2022-12-02T17:16:21.78-0500 [STG/0] OUT checking for ut_read_xml in -ludunits2... no
   2022-12-02T17:16:21.78-0500 [STG/0] OUT configure: error: in `/tmp/Rtmp6YIjSI/R.INSTALL14a13ff22e5/units':
   2022-12-02T17:16:21.78-0500 [STG/0] OUT configure: error:
   2022-12-02T17:16:21.78-0500 [STG/0] OUT --------------------------------------------------------------------------------
   2022-12-02T17:16:21.78-0500 [STG/0] OUT Configuration failed because libudunits2.so was not found. Try installing:
   2022-12-02T17:16:21.78-0500 [STG/0] OUT * deb: libudunits2-dev (Debian, Ubuntu, ...)
   2022-12-02T17:16:21.78-0500 [STG/0] OUT * rpm: udunits2-devel (Fedora, EPEL, ...)
   2022-12-02T17:16:21.78-0500 [STG/0] OUT * brew: udunits (OSX)
   2022-12-02T17:16:21.78-0500 [STG/0] OUT If udunits2 is already installed in a non-standard location, use:
   2022-12-02T17:16:21.78-0500 [STG/0] OUT --configure-args='--with-udunits2-lib=/usr/local/lib'
   2022-12-02T17:16:21.78-0500 [STG/0] OUT if the library was not found, and/or:
   2022-12-02T17:16:21.78-0500 [STG/0] OUT --configure-args='--with-udunits2-include=/usr/include/udunits2'
   2022-12-02T17:16:21.78-0500 [STG/0] OUT if the header was not found, replacing paths with appropriate values.
   2022-12-02T17:16:21.78-0500 [STG/0] OUT You can alternatively set UDUNITS2_INCLUDE and UDUNITS2_LIBS manually.
   2022-12-02T17:16:21.78-0500 [STG/0] OUT --------------------------------------------------------------------------------
   2022-12-02T17:16:21.78-0500 [STG/0] OUT See `config.log' for more details
   2022-12-02T17:16:21.81-0500 [STG/0] OUT ERROR: configuration failed for package ‘units’
   2022-12-02T17:16:21.81-0500 [STG/0] OUT * removing ‘/tmp/contents241212264/deps/0/r/library/units’
   2022-12-02T17:16:21.83-0500 [STG/0] OUT Warning message:
   2022-12-02T17:16:21.83-0500 [STG/0] OUT In install.packages(c("./vendor_r/units_0.8-0.tar.gz"), repos = NULL,  :
   2022-12-02T17:16:21.83-0500 [STG/0] OUT installation of package ‘./vendor_r/units_0.8-0.tar.gz’ had non-zero exit status

@Enchufa2
Copy link
Member

Enchufa2 commented Dec 2, 2022

As the error message points out, you need the udunits2 library, so you'll need to ask an admin with the proper rights to install it, or compile it yourself from source and point to its location following what the error message suggests.

@spfeiffe
Copy link

spfeiffe commented Dec 5, 2022

Ok, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants