Skip to content
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

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

Open
skydivedan opened this issue Jan 19, 2024 · 2 comments
Open

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

skydivedan opened this issue Jan 19, 2024 · 2 comments

Comments

@skydivedan
Copy link

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
Copy link
Author

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.

@Nikoloutsos
Copy link
Contributor

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?

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

No branches or pull requests

2 participants