CRuby builds a ruby binary and scripts with the absolute path hard corded.
$ strings /Users/riywo/.rbenv/versions/1.9.3-p327/bin/ruby | grep rbenv
/Users/riywo/.rbenv/versions/1.9.3-p327
/Users/riywo/.rbenv/versions/1.9.3-p327/lib/ruby/site_ruby/1.9.1
/Users/riywo/.rbenv/versions/1.9.3-p327/lib/ruby/site_ruby/1.9.1/x86_64-darwin12.2.0
/Users/riywo/.rbenv/versions/1.9.3-p327/lib/ruby/site_ruby
/Users/riywo/.rbenv/versions/1.9.3-p327/lib/ruby/vendor_ruby/1.9.1
/Users/riywo/.rbenv/versions/1.9.3-p327/lib/ruby/vendor_ruby/1.9.1/x86_64-darwin12.2.0
/Users/riywo/.rbenv/versions/1.9.3-p327/lib/ruby/vendor_ruby
/Users/riywo/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1
/Users/riywo/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/x86_64-darwin12.2.0
$ head -1 /Users/riywo/.rbenv/versions/1.9.3-p327/bin/gem
#!/Users/riywo/.rbenv/versions/1.9.3-p327/bin/ruby
So, if you move the installed directory location, the ruby and scripts don’t work. To avoid this kind of problems, you can use --enable-load-relative
configure option.
$ RUBY_CONFIGURE_OPTS="--enable-load-relative" rbenv install 1.9.3-p327
$ strings /Users/riywo/.rbenv/versions/1.9.3-p327/bin/ruby | grep rbenv
$ head -8 /Users/riywo/.rbenv/versions/1.9.3-p327/bin/gem
#!/bin/sh
# -*- ruby -*-
bindir=`cd -P "${0%/*}" 2>/dev/null; pwd`
prefix="${bindir%/bin}"
export DYLD_LIBRARY_PATH="$prefix/lib${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}"
exec "$bindir/ruby" -x "$0" "$@"
#!/usr/bin/env ruby
#--
See also Tokaido Status Update: Implementation Details « Katz Got Your Tongue?