Skip to content

The option --follow-symlinks can't follow relative symlinks #836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kkebo opened this issue Oct 5, 2024 · 1 comment · Fixed by #837
Closed

The option --follow-symlinks can't follow relative symlinks #836

kkebo opened this issue Oct 5, 2024 · 1 comment · Fixed by #837

Comments

@kkebo
Copy link
Contributor

kkebo commented Oct 5, 2024

Description

The subcommands lint and format have the option --follow-symlinks. However, although it can follow absolute symlinks, it can't follow relative symlinks.

Steps to reproduce

$ mkdir symlink-test
$ cd symlink-test/
$ echo 'let foo:Int=0' > .foo.swift
$ ln -s .foo.swift bar.swift
$ swift format dump-configuration > .swift-format
$ cd ..
$ swift format lint -rs --follow-symlinks symlink-test/
<unknown>: error: Unable to open .foo.swift: file is not readable or does not exist

If the current working directory is the symlink's directory, it works.

$ cd symlink-test
$ swift format lint -rs --follow-symlinks .
.foo.swift:1:9: warning: [Spacing] add 1 space
.foo.swift:1:12: warning: [Spacing] add 1 space
.foo.swift:1:13: warning: [Spacing] add 1 space

It's because the following line is using relativeTo: workingDirectory.

URL(fileURLWithPath: relativePath, isDirectory: false, relativeTo: workingDirectory)

Environment

  • swift-format (bundled in Swift 6.0.1 toolchain)
  • Debian 12 (aarch64)
@ahoppen
Copy link
Member

ahoppen commented Oct 5, 2024

Synced to Apple’s issue tracker as rdar://137341926

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants