swift icon indicating copy to clipboard operation
swift copied to clipboard

swiftlint: command not found - how can I fix this?

Open skydivedan opened this issue 2 years ago • 2 comments

My environment is CircleCI, just so you know. and this is running as a Mac executor.

My Dangerfile.swift file looks like this:

import Danger
let danger = Danger()

let editedFiles = danger.git.modifiedFiles + danger.git.createdFiles
message("These files have changed: \(editedFiles.joined(separator: ", "))")

SwiftLint.lint()

Now, while Danger does write in my PR about modified and created files, SwiftLint.lint() run, and gives this error: /bin/sh: swiftlint: command not found

Why would that be? The "danger-swift" Package contains SwiftLint as a dependency, so wouldn't it be able to run SwiftLint? Do I need to actually install SwiftLint? If so, then what does the SwiftLint dependency do?

skydivedan avatar Jan 19 '24 14:01 skydivedan

additionally, the docs say that when building my Package.swift file, I should add the the target like this: .target(name: "eigen", dependencies: ["Danger"], path: "Artsy", sources: ["Stringify.swift"]),

Which I was unable to do exactly.... mine looks like this: .target(name: "eigen", dependencies: [.product(name: "Danger", package: "swift")], path: "Artsy", sources: ["Stringify.swift"]),

When I do this, Package.resolved does not include Swiftlint. The result of Package.resolved behaves as if isDevelop is false -- which is weird considering that I can see that it's set to true right in the Package.swift file itself. So, I don't know why I'm seeing this behavior.

skydivedan avatar Jan 19 '24 15:01 skydivedan

A quick fix would be to run something like: brew install swiftlint on your CI.

And in case you don't want to waste time on installing swiftlint you can always provide it as an executable. You can do that by setting the swiftlintPath property to .bin(<Path>).

Why would that be? The "danger-swift" Package contains SwiftLint as a dependency, so wouldn't it be able to run SwiftLint?

No I don't think that this is true. Are you using the --cwd on the command? May you please share it with us?

Nikoloutsos avatar May 28 '24 11:05 Nikoloutsos