diff --git a/internal/lookup/symlinks.go b/internal/lookup/symlinks.go index 002783cb..495ad87e 100644 --- a/internal/lookup/symlinks.go +++ b/internal/lookup/symlinks.go @@ -103,14 +103,23 @@ func (p symlink) Locate(pattern string) ([]string, error) { if err != nil { return nil, err } - if len(candidates) != 1 { - return nil, fmt.Errorf("failed to uniquely resolve symlink %v: %v", pattern, candidates) + + var targets []string + seen := make(map[string]bool) + for _, candidate := range candidates { + target, err := filepath.EvalSymlinks(candidate) + if err != nil { + return nil, fmt.Errorf("failed to resolve link: %w", err) + } + if seen[target] { + continue + } + seen[target] = true + targets = append(targets, target) } - target, err := filepath.EvalSymlinks(candidates[0]) - if err != nil { - return nil, fmt.Errorf("failed to resolve link: %v", err) + if len(targets) != 1 { + return nil, fmt.Errorf("failed to locate patern %q: failed to uniquely resolve symlink: %v", pattern, targets) } - - return []string{target}, err + return targets, err }