Fix realpath handling for non-existent paths