installationmacos-sierraxapian

MacOs 10.12.6 : Error while installing Xapian : Operation Not permitted


I'm trying to install xapian from source on MACOS 10.12.6. I am able to build the source but unable to install it ,

the error is :

/bin/sh ../libtool   --mode=install /usr/bin/install -c   xapian.la 
'/usr/lib/php/extensions/no-debug-non-zts-20131226'
libtool: install: /usr/bin/install -c .libs/xapian.so 
/usr/lib/php/extensions/no-debug-non-zts-20131226/xapian.so
install: /usr/lib/php/extensions/no-debug-non-zts-20131226/xapian.so: 
Operation not permitted
make[5]: *** [install-phpextLTLIBRARIES] Error 71
make[4]: *** [install-am] Error 2

I followed these steps in the xapian directory :

./bootstrap
./configure --without-perl --without-tcl --prefix='/usr/local'
make
sudo make install

Would be great if anyone could suggest how to resolve this error .


Solution

  • Recent macOS versions come with something called "System Integrity Protection" (or SIP), which prevents you (even as root) from installing files in certain places on the operating system. You have three main options:

    1. Turn off SIP (this is pretty drastic, and most people won't want to do that).

    2. Install the PHP extension to a custom location: sudo make install PHP_EXTENSION_DIR=$HOME/php-local. You'll then need to set PHP's extension_dir to find it, something like php -d extension_dir=$HOME/php-local -r 'require_once("xapian.php");'. In this case, you probably want to set PHP_EXTENSION_DIR to something like /usr/local/lib/php/extensions.

    3. Install PHP from homebrew: brew tap homebrew/homebrew-php and build the Xapian bindings against that (this may involve more effort).

    Of course, if you don't need PHP bindings, you can disable building them in the same way you're disabling Perl and TCL bindings (which have the same problem on macOS): ./configure --without-perl --without-tcl --without-php --prefix=/usr/local.