Compile Psych to link with @executable_path?

Hello,

Compiling Ruby with “–enable-load-relative” sets the binary to link to
relative lib paths. Note the @executable_path below:

$ otool -L /Applications/Vagrant/embedded/bin/ruby
/Applications/Vagrant/embedded/bin/ruby:
@executable_path/…/lib/libruby.1.9.1.dylib (compatibility version
1.9.1, current version 1.9.1)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 159.1.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version
228.0.0)

This allows me to move around the entire installation folder without
links breaking. Unfortunately, it appears this doesn’t happen with
libyaml on the Psych bundle. Notice below that libruby is linked to with
@executable_path but libyaml is still linked with an absolute path.

$ otool -L
/Applications/Vagrant/embedded/lib/ruby/1.9.1/universal-darwin11.2.0/psych.bundle
/Applications/Vagrant/embedded/lib/ruby/1.9.1/universal-darwin11.2.0/psych.bundle:
@executable_path/…/lib/libruby.1.9.1.dylib (compatibility version
1.9.1, current version 1.9.1)
/tmp/vagrant-temp/embedded/lib/libyaml-0.2.dylib (compatibility
version 3.0.0, current version 3.2.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 159.1.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version
228.0.0)

While compiling Ruby, is there a way to specify to Psych to use a
relative @executable_path as well?

Mitchell

On Wed, Jan 18, 2012 at 1:58 AM, Mitchell H.
[email protected] wrote:

Hello,

Compiling Ruby with “–enable-load-relative” sets the binary to link to
relative lib paths.

While compiling Ruby, is there a way to specify to Psych to use a
relative @executable_path as well?

I had a similar problem and ended up using install_name_tool to
workaround the problem. I didn’t try it with @executable_path (I
needed a new fixed path to libyaml) but I believe it will work. See:

Creating working dylibs

I use a script to build ruby so I just added this extra step to the
script. Something like:

$ install_name_tool -change OLD_PATH NEW_PATH path/to/psych.bundle

HTH,
Ammar