Skip to content

Instantly share code, notes, and snippets.

@vargeorge
Created October 5, 2012 20:09
Show Gist options
  • Save vargeorge/3842072 to your computer and use it in GitHub Desktop.
Save vargeorge/3842072 to your computer and use it in GitHub Desktop.
Mac OS X: sudo install_name_tool -change does not work; How to fix it?
Issue:
$ sudo install_name_tool -change completes without errors however running "otool -L shows that the dylib has not been changed.
e.g.
$ sudo install_name_tool -change ~/Download/mysql-5.5.28/libmysql/libmysqlclient.18.dylib /Applications/MAMP/Library/lib/libmysqlclient.18.dylib ~/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
$ otool -L ~/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
/Users/username/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle:
/Users/username/.rvm/rubies/ruby-1.9.3-p194/lib/libruby.1.9.1.dylib (compatibility version 1.9.1, current version 1.9.1)
/Users/username/Downloads/mysql-5.5.28/libmysql/libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
Solution:
Make sure to use absolute path starting with / instead of using ~/path/to/file. the following changes work as expected for the above example.
$ sudo install_name_tool -change /Users/username/Downloads/mysql-5.5.28/libmysql/libmysqlclient.18.dylib /Applications/MAMP/Library/lib/libmysqlclient.18.dylib /Users/username/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
otool -L ~/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
/Users/username/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle:
/Users/username/.rvm/rubies/ruby-1.9.3-p194/lib/libruby.1.9.1.dylib (compatibility version 1.9.1, current version 1.9.1)
/Applications/MAMP/Library/lib/libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment