David Luque
David Luque

Reputation: 1108

ln: /usr/lib/libssl.dylib: Operation not permitted OSX

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?

Upvotes: 8

Views: 16315

Answers (4)

MS Berends
MS Berends

Reputation: 5249

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
    

Upvotes: 0

Robert Lujo
Robert Lujo

Reputation: 16371

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 ....

Upvotes: 0

notthehoff
notthehoff

Reputation: 1242

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

Upvotes: 7

David Luque
David Luque

Reputation: 1108

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

Upvotes: 0

Related Questions