danger / swift

⚠️ Stop saying "you forgot to …" in code review
https://danger.systems/swift/
MIT License
1.05k stars 141 forks source link

ERROR: Could not find a libDanger to link against #541

Open benjaminbreier opened 1 year ago

benjaminbreier commented 1 year ago

Hi, I am experiencing an error when trying to run danger-swift built with SPM.

After running npm install -g danger swift build swift run danger-swift edit

I get the following error:

 ERROR: Could not find a libDanger to link against at any of: [".build/debug", ".build/x86_64-unknown-linux/debug", ".build/release", "/usr/local/lib/danger", "/opt/homebrew/lib/danger"]
Or via Homebrew, or Marathon

My Package.swift:

// swift-tools-version:5.5
import PackageDescription

let package = Package(
    name: "DangerDependencies",
    products: [
        .library(
            name: "DangerDeps",
            type: .dynamic,
            targets: ["DangerDependencies"]),
    ],
    dependencies: [
        .package(url: "https://github.com/danger/swift.git", from: "3.14.2"),
    ],
    targets: [
        .target(
            name: "DangerDependencies",
            dependencies: [
                .product(name: "Danger", package: "swift"),
            ]), 
    ])

There is a libDangerDeps.dylib in .build/debug but of course, no libDanger.dylib. I've tried a plethora of solutions gleaned from searching the issues on the repository to no avail. What have I missed?

MarcoSantarossa commented 1 year ago

We are having the same issue. @benjaminbreier were you able to find a fix for this error ?

f-meloni commented 1 year ago

Hey :) Your config seems correct to me :( Few questions just to debug the issue: Are you running the command from the folder where the Package.swift is? Can you please post me the content of your .build/debug (or release)? Thank you :)

benjaminbreier commented 1 year ago

Hey :) Your config seems correct to me :( Few questions just to debug the issue: Are you running the command from the folder where the Package.swift is? Can you please post me the content of your .build/debug (or release)? Thank you :)

I am running the command from the folder where Package.swift is. I cannot post the content of .build/debug at this time.

@MarcoSantarossa I found that manually renaming libDangerDeps.dylib to libDanger.dylib does solve the issue.

MarcoSantarossa commented 1 year ago

@f-meloni we are are still facing this issue after updating to the latest version. It was working with a with 3.14.0. Were you able to reproduce it by any chance ? It happens in both m1 and intel macOS. We noticed that it happens only if we install via SPM but it doesn't happen if we install it via brew.

Are you running the command from the folder where the Package.swift is?

Yes

Can you please post me the content of your .build/debug (or release)?

image

arde02 commented 1 year ago

Experiencing this same issue.

ryancrosby commented 1 year ago

I ran into this issue as well. Two things helped me solve it:

  1. Running swift build creates the dylib file, swift run does not generate it. Probably intuitive once someone has worked with swift tooling for awhile, but I am still fairly new to this.
  2. The product is what the name of the dylib is derived from. So I renamed my product to (my naming is slightly different).

    .library(name: "Danger", type: .dynamic, targets: ["BuildTools"])

    Hopefully that helps anyone else experiencing this.