It was chopping off an extra directory level due to realpath removing the trailing / from the paths when they are setup.