updates to change $: when the executable is really a symlink
use File.realdirpath to resolve symlinks