8

I'm trying to create a symbolic link to /usr/lib but I seems I have not permission, included with root. The system is return that the operations is not permitted.

With Yosemite I worked fine, but with El Capitan it broke :/

Anyone know what I can do?

0

4 Answers 4

7

I had some issues using the linked subl command for Sublime text 3. It was the same issue you encountered, I believe.

Apparently, usr/local does not have the same controls on it. So instead of

ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl

as recommended by Sublime docs,

it was more along the lines of:

ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" usr/local/bin/subl
0

Ok, I solved it using this command in the Recovery mode:

csrutil disable

Apple has created a new flag named "restricted" which limit the access to files and folders that execute in this mode. Then, I copy the files and created the symbolic links again and It works.

sudo cp /Library/PostgreSQL/9.2/lib/libssl.1.0.0.dylib /usr/lib
sudo cp /Library/PostgreSQL/9.2/lib/libcrypto.1.0.0.dylib /usr/lib

sudo ln -fs /usr/lib/libssl.1.0.0.dylib /usr/lib/libssl.dylib
sudo ln -fs /usr/lib/libcrypto.1.0.0.dylib /usr/lib/libcrypto.dylib
2
  • 5
    Local customizations like this really belong in /usr/local (see notthehoff's answer). Apple's now enforcing this as a rule. Disabling system integrity protection so you can continue doing it wrong is a bad idea on several levels Oct 2, 2015 at 16:38
  • Turning off rootless mode is quite reckless and dangerous. There are better solutions that also do not require to redo this with every OS update.
    – MS Berends
    Oct 21, 2020 at 11:45
0

I would suggest not to mess with system directories any more due security reasons and complexity and sensitivity of the security disabling process (rootless mode and csrutil disable).

If you have issues with development libraries used from terminal/shell programs (rails, django, python, ruby, php, ...) - I would suggest following alternative:

  • install new version of library somewhere/somehow (e.g. brew install ...)
  • setup DYLD_LIBRARY_PATH in .bash_profile to location where new lib*.dylib(s) are located
  • restart shell
  • reinstall/recompile the library which needed different version of system library - new version libraries should be found and linked

For example check python->postgres-driver->openssl/libssl.dylib on https://stackoverflow.com/a/33034764/565525) - issue was Incompatible library version: _psycopg.so requires version 1.0.0 or later ....

0

What you actually need to do is redirect to the original binary, not changing the contents of /usr/lib/. Running csrutil disable is very bad and dangerous behaviour, it's called 'rootless' for a reason.

If you get an error like:

dlopen(/Users/{your_username}/Library/R/4.0/library/sf/libs/sf.so, 6):
Library not loaded: /usr/lib/libpq.5.dylib

Then the solution would be to:

  1. Find libpq.5.dylib on your system, because it is definitely somewhere:

    ~ % sudo find / -name libpq.5.dylib
    # /usr/local/opt/libpq/lib/libpq.5.dylib 
    
  2. Use that file to redirect using install_name_tool:

     sudo install_name_tool -change /usr/lib/libpq.5.dylib /usr/local/opt/libpq/lib/libpq.5.dylib /Users/{your_username}/Library/R/4.0/library/sf/libs/sf.so
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.