use pathname instead of expand_path to resolve symlinks