Skip to content

excluded paths ignored when project is under /private (e.g. /tmp, mktemp, CI workspaces) — regression in 0.64.0 #6782

Closed

Description

@tumata

New Issue Checklist

Describe the bug

excluded paths are silently ignored, and the files get linted anyway, when the project's real path is located under /private (which on macOS includes anything under /tmp, /var, and /var/folders, since those are symlinks to /private/tmp, /private/var, …).

The same project, same config, and same SwiftLint binary work correctly when the project lives under a non-/private path such as /Users/....

This is a regression in 0.64.0. 0.63.3 excludes the files correctly in the exact same location.

This bites in practice because:

  • Many CI systems run jobs out of a workspace under /private/var/....
  • Anything created with mktemp -d (tests, scripts, scratch repos) lands under /private/var/folders/....

In both cases, files that should be excluded (e.g. generated code) start failing the lint, with no config change.

Complete output when running SwiftLint

Self-contained reproduction (paste into a terminal on macOS):

# mktemp -d returns a path under /var/folders -> /private/var/folders
D=$(mktemp -d)
mkdir -p "$D/Sources/Feature/Sources"
printf 'let value = Optional(1)!\n' > "$D/Sources/Feature/Sources/Generated.swift"
cat > "$D/.swiftlint.yml" <<'EOF'
included:
  - Sources
excluded:
  - Sources/**/Generated.swift
opt_in_rules:
  - force_unwrapping
EOF
cd "$D" && swiftlint lint --quiet

Actual (0.64.0): the excluded file is linted

.../Sources/Feature/Sources/Generated.swift:1:24: warning: Force Unwrapping Violation: Force unwrapping should be avoided. (force_unwrapping)

Expected (and actual on 0.63.3): no output.Generated.swift is excluded.

Isolating the trigger

Same project (Sources/Feature/Sources/Generated.swift, same .swiftlint.yml), SwiftLint 0.64.0, only the location differs:

Project real path excluded honored?
/Users/<me>/sl-repro ✅ yes (no violations)
/private/tmp/sl-repro (also via the /tmp symlink) ❌ no (file linted)
/private/var/folders/.../sl-repro (mktemp -d) ❌ no (file linted)

0.63.3 honors excluded in all of these locations. It is not about how you cd into the directory (canonical path vs. via the /tmp symlink behaves the same), it depends on whether the project's real path is under /private.

I tried several config variants under 0.64.0, none restored the exclusion in a /private location:

  • Sources/**/Generated.swift (glob)
  • **/Generated.swift (leading globstar)
  • Sources/Feature/Sources/Generated.swift (explicit, no glob)

Environment

  • SwiftLint version: 0.64.0 (regression from 0.63.3, which works)
  • Installation: Homebrew (also reproduced with the portable_swiftlint.zip release binaries for both versions)
  • Xcode / OS: macOS
  • Paths involved are all under /private via the standard macOS /tmp → /private/tmp and /var → /private/var symlinks

Likely cause

Looks like a path-normalization mismatch introduced in 0.64.0: the lint-target file paths and the resolved excluded patterns end up standardized differently with respect to the leading /private. macOS NSString.standardizingPath strips a leading /private (so /private/var/x → /var/x), while symlink resolution goes the other way (/var/x → /private/var/x). If one side is standardized and the other is symlink-resolved, the exclusion comparison never matches for any path under /private, which is exactly the observed behavior. Under /Users neither transform changes the path, so exclusion still matches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions