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

Installation on macOS fails to find brew libudunits #384

Closed
t-kalinowski opened this issue Feb 5, 2025 · 5 comments · Fixed by #385
Closed

Installation on macOS fails to find brew libudunits #384

t-kalinowski opened this issue Feb 5, 2025 · 5 comments · Fixed by #385

Comments

@t-kalinowski
Copy link
Contributor

t-kalinowski commented Feb 5, 2025

Console session of an installation attempt of the dev package on a pretty vanilla macOS setup:

tomasz@tomaszkalinows-WQVX units % brew install udunits 
Warning: udunits 2.2.28 is already installed and up-to-date.
To reinstall 2.2.28, run:
  brew reinstall udunits
tomasz@tomaszkalinows-WQVX units % Rscript -e 'remotes::install_local()'

── R CMD build ─────────────────────────────────────────────────────────────────
   checking for file ‘/private/var/folders/bg/pzsh15_96957bg6ylzt60tyc0000gp/T/R✔  checking for file ‘/private/var/folders/bg/pzsh15_96957bg6ylzt60tyc0000gp/T/RtmpXE3bKJ/file10f3d7616dbea/units/DESCRIPTION’
─  preparing ‘units’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
─  running ‘cleanup’
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘units_0.8-6.tar.gz’
   
Installing package into ‘/Users/tomasz/Library/R/arm64/4.4/library’
(as ‘lib’ is unspecified)
* installing *source* package ‘units’ ...
** using staged installation
configure: units: 0.8-6
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 the compiler supports GNU C++... yes
checking whether clang++ -arch arm64 -std=gnu++17 accepts -g... yes
checking for clang++ -arch arm64 -std=gnu++17 option to enable C++11 features... none needed
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for _Bool... no
checking for stdbool.h that conforms to C99 or later... yes
checking for error_at_line... no
checking for gcc... clang -arch arm64
checking whether the compiler supports GNU C... yes
checking whether clang -arch arm64 accepts -g... yes
checking for clang -arch arm64 option to enable C11 features... none needed
checking for XML_ParserCreate in -lexpat... yes
checking for udunits2.h... no
checking for udunits2/udunits2.h... no
checking for ut_read_xml in -ludunits2... no
configure: error: in '/private/var/folders/bg/pzsh15_96957bg6ylzt60tyc0000gp/T/Rtmpg7l1oF/R.INSTALL10f8e160a3137/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
ERROR: configuration failed for package ‘units’
* removing ‘/Users/tomasz/Library/R/arm64/4.4/library/units’
* restoring previous ‘/Users/tomasz/Library/R/arm64/4.4/library/units’
Warning message:
In i.p(...) :
  installation of package ‘/var/folders/bg/pzsh15_96957bg6ylzt60tyc0000gp/T//RtmpXE3bKJ/file10f3d1ce6160b/units_0.8-6.tar.gz’ had non-zero exit status
tomasz@tomaszkalinows-WQVX units % find /opt/homebrew/lib | grep udunits
/opt/homebrew/lib/libudunits2.0.dylib
/opt/homebrew/lib/libudunits2.a
/opt/homebrew/lib/libudunits2.dylib
tomasz@tomaszkalinows-WQVX units % find /opt/homebrew | grep udunits 
/opt/homebrew/bin/udunits2
/opt/homebrew/include/udunits.h
/opt/homebrew/include/udunits2.h
/opt/homebrew/var/homebrew/linked/udunits
/opt/homebrew/lib/libudunits2.0.dylib
/opt/homebrew/lib/libudunits2.a
/opt/homebrew/lib/libudunits2.dylib
/opt/homebrew/opt/udunits
/opt/homebrew/Cellar/udunits
/opt/homebrew/Cellar/udunits/2.2.28
/opt/homebrew/Cellar/udunits/2.2.28/INSTALL_RECEIPT.json
/opt/homebrew/Cellar/udunits/2.2.28/bin
/opt/homebrew/Cellar/udunits/2.2.28/bin/udunits2
/opt/homebrew/Cellar/udunits/2.2.28/.brew
/opt/homebrew/Cellar/udunits/2.2.28/.brew/udunits.rb
/opt/homebrew/Cellar/udunits/2.2.28/include
/opt/homebrew/Cellar/udunits/2.2.28/include/udunits.h
/opt/homebrew/Cellar/udunits/2.2.28/include/converter.h
/opt/homebrew/Cellar/udunits/2.2.28/include/udunits2.h
/opt/homebrew/Cellar/udunits/2.2.28/sbom.spdx.json
/opt/homebrew/Cellar/udunits/2.2.28/README
/opt/homebrew/Cellar/udunits/2.2.28/lib
/opt/homebrew/Cellar/udunits/2.2.28/lib/libudunits2.0.dylib
/opt/homebrew/Cellar/udunits/2.2.28/lib/libudunits2.a
/opt/homebrew/Cellar/udunits/2.2.28/lib/libudunits2.dylib
/opt/homebrew/Cellar/udunits/2.2.28/COPYRIGHT
/opt/homebrew/Cellar/udunits/2.2.28/share
/opt/homebrew/Cellar/udunits/2.2.28/share/info
/opt/homebrew/Cellar/udunits/2.2.28/share/info/udunits2.info
/opt/homebrew/Cellar/udunits/2.2.28/share/info/udunits2prog.info
/opt/homebrew/Cellar/udunits/2.2.28/share/info/udunits2lib.info
/opt/homebrew/Cellar/udunits/2.2.28/share/doc
/opt/homebrew/Cellar/udunits/2.2.28/share/doc/udunits
/opt/homebrew/Cellar/udunits/2.2.28/share/doc/udunits/udunits2-prefixes.xml
/opt/homebrew/Cellar/udunits/2.2.28/share/doc/udunits/udunits2.xml
/opt/homebrew/Cellar/udunits/2.2.28/share/doc/udunits/CHANGE_LOG
/opt/homebrew/Cellar/udunits/2.2.28/share/doc/udunits/README
/opt/homebrew/Cellar/udunits/2.2.28/share/doc/udunits/udunits2-common.xml
/opt/homebrew/Cellar/udunits/2.2.28/share/doc/udunits/udunits2-derived.xml
/opt/homebrew/Cellar/udunits/2.2.28/share/doc/udunits/COPYRIGHT
/opt/homebrew/Cellar/udunits/2.2.28/share/doc/udunits/udunits2-accepted.xml
/opt/homebrew/Cellar/udunits/2.2.28/share/doc/udunits/udunits2-base.xml
/opt/homebrew/Cellar/udunits/2.2.28/share/udunits
/opt/homebrew/Cellar/udunits/2.2.28/share/udunits/udunits2-prefixes.xml
/opt/homebrew/Cellar/udunits/2.2.28/share/udunits/udunits2.xml
/opt/homebrew/Cellar/udunits/2.2.28/share/udunits/udunits2-common.xml
/opt/homebrew/Cellar/udunits/2.2.28/share/udunits/udunits2-derived.xml
/opt/homebrew/Cellar/udunits/2.2.28/share/udunits/udunits2-accepted.xml
/opt/homebrew/Cellar/udunits/2.2.28/share/udunits/udunits2-base.xml
/opt/homebrew/share/info/udunits2.info
/opt/homebrew/share/info/udunits2prog.info
/opt/homebrew/share/info/udunits2lib.info
/opt/homebrew/share/doc/udunits
/opt/homebrew/share/udunits
@t-kalinowski
Copy link
Contributor Author

For others that run into the issue, one simple fix is to set the env vars (possibly in .Renviron if you're iterating on the dev version of the package):

UDUNITS2_LIBS='/opt/homebrew/lib/' UDUNITS2_INCLUDE='/opt/homebrew/include/' Rscript -e 'remotes::install_local()'

However, I think {units} should find these locations automatically. Since the x86->arm transition, this is the new default homebrew install location.

@Enchufa2
Copy link
Member

Enchufa2 commented Feb 5, 2025

This is useful, thanks! I wondered why package checks with r-lib/actions started to fail on macOS, because we don't do anything special to find Homebrew. So I suppose that it was in some standard location before (like /usr/local/include), and now it's in /opt, right? Not being a macOS user myself, I only came up with this workaround, but your solution is much more general, so I think that I can add something to the configure script to account for this.

@t-kalinowski
Copy link
Contributor Author

t-kalinowski commented Feb 5, 2025

I think the most portable way to get the homebrew prefix would be to use brew --prefix (or the corresponding envvar, if it has been set). For example:

UDUNITS2_LIBS=$(brew --prefix)/lib/
UDUNITS2_INCLUDE=$(brew --prefix)/include/

That said, I expect most users use the default location, and hardcoding /opt/homebrew/ in the search path on macOS should be fine.

@Enchufa2
Copy link
Member

Enchufa2 commented Feb 5, 2025

Could you please check if the brew branch solves this issue?

@t-kalinowski
Copy link
Contributor Author

It works! It installed without any special config needed. 🎉

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

Successfully merging a pull request may close this issue.

2 participants