Skip to content

Installation failure on macOS 10.14 #232

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

Closed
jonclayden opened this issue Sep 28, 2018 · 10 comments
Closed

Installation failure on macOS 10.14 #232

jonclayden opened this issue Sep 28, 2018 · 10 comments

Comments

@jonclayden
Copy link

I apologise if this is something stupid, but I really can't see what I'm doing wrong here. I have updated this machine to macOS Mojave, using Homebrew-installed R. I can't get xml2 to install, either with the system libxml2 or the one from Homebrew:

$ R CMD INSTALL xml2_1.2.0.tar.gz 
* installing to library ‘/usr/local/lib/R/3.5/site-library’
* installing *source* package ‘xml2’ ...
** package ‘xml2’ successfully unpacked and MD5 sums checked
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/libxml2
Using PKG_LIBS=-L/usr/lib -lxml2 -lz -lpthread -licucore -lm
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libxml-2.0 was not found. Try installing:
 * deb: libxml2-dev (Debian, Ubuntu, etc)
 * rpm: libxml2-devel (Fedora, CentOS, RHEL)
 * csw: libxml2_dev (Solaris)
If libxml-2.0 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libxml-2.0.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: configuration failed for package ‘xml2’
* removing ‘/usr/local/lib/R/3.5/site-library/xml2’
$ R CMD INSTALL --configure-vars='INCLUDE_DIR=/usr/local/opt/libxml2/include LIB_DIR=/usr/local/opt/libxml2/lib' xml2_1.2.0.tar.gz 
* installing to library ‘/usr/local/lib/R/3.5/site-library’
* installing *source* package ‘xml2’ ...
** package ‘xml2’ successfully unpacked and MD5 sums checked
Found INCLUDE_DIR and/or LIB_DIR!
Using PKG_CFLAGS=-I/usr/local/opt/libxml2/include 
Using PKG_LIBS=-L/usr/local/opt/libxml2/lib -lxml2
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libxml-2.0 was not found. Try installing:
 * deb: libxml2-dev (Debian, Ubuntu, etc)
 * rpm: libxml2-devel (Fedora, CentOS, RHEL)
 * csw: libxml2_dev (Solaris)
If libxml-2.0 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libxml-2.0.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: configuration failed for package ‘xml2’
* removing ‘/usr/local/lib/R/3.5/site-library/xml2’

Note that in both cases, pkg-config provides suitable flags, but the configuration rejects them. Any pointers would be appreciated. Session info is below (FWIW):

$ Rscript -e "devtools::session_info()"
Session info ------------------------------------------------------------------
 setting  value                       
 version  R version 3.5.1 (2018-07-02)
 system   x86_64, darwin18.0.0        
 ui       unknown                     
 language (EN)                        
 collate  en_GB.UTF-8                 
 tz       Europe/London               
 date     2018-09-28                  

Packages ----------------------------------------------------------------------
 package   * version date       source        
 base      * 3.5.1   2018-08-21 local         
 compiler    3.5.1   2018-08-21 local         
 datasets  * 3.5.1   2018-08-21 local         
 devtools    1.13.6  2018-06-27 CRAN (R 3.5.1)
 digest      0.6.17  2018-09-12 CRAN (R 3.5.1)
 graphics  * 3.5.1   2018-08-21 local         
 grDevices * 3.5.1   2018-08-21 local         
 memoise     1.1.0   2017-04-21 CRAN (R 3.5.1)
 methods   * 3.5.1   2018-08-21 local         
 stats     * 3.5.1   2018-08-21 local         
 utils     * 3.5.1   2018-08-21 local         
 withr       2.1.2   2018-03-15 CRAN (R 3.5.1)
@jonclayden
Copy link
Author

Oh, fun – /usr/include is gone under Xcode 10, and you have to install a separate package to get it back.

And it seems that the Homebrew include path should be /usr/local/opt/libxml2/include/libxml2.

Either works. Apologies for the noise.

@xiaokunx
Copy link

Thanks for sharing on this topic!

I initially followed the second solution:

  1. download source pkg xml2_1.2.0.tar.gz from its CRAN repo
  2. brew install libxml2
  3. R CMD INSTALL --configure-vars='INCLUDE_DIR=/usr/local/opt/libxml2/include/libxml2 LIB_DIR=/usr/local/opt/libxml2/lib/' xml2_1.2.0.tar.gz
    but the problem persists.

After about another hour of googling, finally found how to implement the first solution: udo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target, thanks to this nice tutorial about setup_macOS_for_R. With this Mac package (not a R package!) installed, simply run install.packages('xml2') inside R console just worked.

@jeongyoonlee
Copy link

After about another hour of googling, finally found how to implement the first solution: udo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target, thanks to this nice tutorial about setup_macOS_for_R. With this Mac package (not a R package!) installed, simply run install.packages('xml2') inside R console just worked.

There's a typo. The full command is as follows:
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

@ryudice
Copy link

ryudice commented Feb 12, 2019

Thanks a lot, this worked

@slhck
Copy link

slhck commented Mar 28, 2019

The suggestions from @jeongyoonlee worked for me initially, but then, I think I did a macOS upgrade that included Xcode, and installing the xml2 package stopped working again with the same error.

I had to re-run the command to install the headers. Then, everything worked.

So: If you update Xcode, re-run the installation.

Edit: This also seems to apply if you update macOS itself.

@tko
Copy link

tko commented May 28, 2019

Would it be possible to make installation just work without the extra manual steps? Or when the installation fails print a quick tip for macos like there's for deb/rpm/csw?

As the workaround for macos seems to be considered "legacy" it may not be around for too long so making things "just work" would be preferable, IMO.

For legacy software that looks for the macOS headers in the base system under /usr/include, please install the package file located at: /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14. pkg

-- https://forums.developer.apple.com/thread/104296#317543

@RLumSK
Copy link

RLumSK commented Jun 5, 2019

It appears that with the new Command Line Tool for Xcode 11 just shipped via an update by Apple the
macOS_SDK_headers_for_macOS_10.14.pkg option does not work anymore (the folder 'Packages' is gone and will not come back).

Nevertheless, to fulfill CRAN requirements and test your package with R-devel (i.e. compiling the 'xml2' package first), I had to use (written already above, libxml2 via homebrew) in the R terminal:

install.packages("xml2", configure.vars='INCLUDE_DIR=/usr/local/opt/libxml2/include/libxml2 LIB_DIR=/usr/local/opt/libxml2/lib/')

@bcolferzd
Copy link

bcolferzd commented Jun 12, 2019

For me brew install libxml2 then install.packages("xml2") worked for me

@j450h1
Copy link

j450h1 commented Mar 11, 2020

For me brew install libxml2 then install.packages("xml2") worked for me.

Didn't work for me on macOS 10.15.3 (Catalina)

However, the one above it did the trick.

install.packages("xml2", configure.vars='INCLUDE_DIR=/usr/local/opt/libxml2/include/libxml2 LIB_DIR=/usr/local/opt/libxml2/lib/')

@nroak
Copy link

nroak commented Apr 28, 2020

Thank you, this was helpful to point me in the right direction. ALthough the Packages directory was missing from my CommandLineTools. i reinstalled Xcode and it worked like a charm:

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
cd /Library/Developer/CommandLineTools/Packages/
open macOS_SDK_headers_for_macOS_10.14.pkg

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

10 participants