The El Capitan release of OS X introduces a more strict security model around the concept of root level access to the underpinnings of the operating system. For a typical user, this is great news for avoiding malware, etc.
As a developer, this requires a little more thoughtfulness when trying to behave as root. Even with the
sudo command, there are protected locations and processes that will no longer work as expected. To be specific
/usr/bin for this example.
This command will NOT work in OS X 10.11:
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/bin --filename=composer
Yields an error, unable to write to the global path.
Downloading... Could not create file /usr/bin/composer: fopen(/usr/bin/composer): failed to open stream: Operation not permitted Download failed: fopen(/usr/bin/composer): failed to open stream: Operation not permitted fwrite() expects parameter 1 to be resource, boolean given
Instead, let's write to the
/usr/local/bin path for the user:
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Now we can access the
composer command globally, just like before.