Could not find a libDanger
Hi, I am trying to install Danger in M1 macbook pro. I tried installing with Brew and SPM, but when I try to do
swift run danger-swift pr {url} or danger-swift edit
I get the below 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"]
Or via Homebrew, or Marathon
Any help will be much appreciated. Thanks
Can you please show me your Package.swift?
That error is usualy really common in the SPM configuration when Danger is not linked to a target that can be build before the compilation, so there is no library when it goes to compile the Danger
Hi everybody,
I have the same problem (also on an M1 processor).
But I installed dangerswift via brew:
npm install -g danger
brew install danger / tap / danger-swift
brew install swiftlint
Any help will be much appreciated. Thanks
You (also) should post your package.swift like the comment above recommends
Hi @orta & @f-meloni !
Thanks for your feedback.
I don't use a package.swift yet. (I thought it can also work without Package.swift)
I start danger via
danger-swift ci via Gitlab
on a Mac-Mini with M1 (Apple Silicon)
I noticed that the path /usr/local/lib/danger is stored in Runtime.swift -> potentialLibraryFolders (See here) .
Unfortunately usr/local/lib does not exist on the Mac Mini M1.
I have created a link lib in /usr/local/ as a workaround:
sudo ln -sf /opt/homebrew/lib/danger danger
The error message (ERROR: Could not find a libDanger to link ...) disappeared but a new error occurs:
/var/folders/wd/sdhj62j149q08d18m94g4p0r0000gn/T/_tmp_dangerfile.swift:1:8: error: module 'Danger' was created for incompatible target arm64-apple-macosx10.10: /usr/local/lib/danger/Danger.swiftmodule
import danger
Ok, this is really interesting.
I think there are two different things to fix then, the first one is find where homebrew saves the installed tools if there is no usr/local/lib I suppose on /opt/homebrew/lib/danger, so we sshould just add it to the potentialLibraryFolders and that should do it.
The other thing is error: module 'Danger' was created for incompatible target arm64-apple-macosx10.10, I think there is an incompatibility issue, this might be harder to debug because I don't have an M1 device 🤔
We are having the same issue on M1 MacMinis. Is the new ARM architecture supported?
Package.swift
import PackageDescription
let package = Package(
name: "DangerTarget",
products: [
.library(
name: "DangerDeps",
type: .dynamic,
targets: ["DangerDependencies"]),
],
dependencies: [
.package(url: "https://github.com/danger/swift.git", from: "3.10.1")
],
targets: [
.target(
name: "DangerDependencies",
dependencies: ["Danger"]
),
]
)
Command:
swift run danger-swift ci -d "../Dangerfile.swift" --failOnErrors false --verbose
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"]
Or via Homebrew, or Marathon
I had a similar issue with similar package.swift file mentioned by @peterlendvay , the workaround I applied was running
swift build -c release --product Danger # this will build `libDanger`
swift run danger-swift ci -c release
Danger-swift seems to work fine after this workaround.
the first one is find where homebrew saves the installed tools if there is no
usr/local/libI suppose on/opt/homebrew/lib/danger, so we sshould just add it to thepotentialLibraryFoldersand that should do it.
@f-meloni looks like there are two similar threads. This looks promising. It would make sense because of the 2.6.0 Homebrew release.
@f-meloni I was doing some digging, and it looks like the potentialLibraryFolders is already updated in master. Is this being tested already? Any ETA on when we can use that?
@morluna Yes is been introduced in https://github.com/danger/swift/pull/458
I can make a realease so that can be tested
I've released 3.11.0 with this change
Thanks @f-meloni.
ERROR: Could not find a libDanger issue is fixed with this release.
But there's a new issue.
/var/folders/f2/dngvlrg54f968wxfzlqv0k7r0000gp/T/_tmp_dangerfile.swift:1:8: error: module 'Danger' was created for incompatible target arm64-apple-macosx10.10: /opt/homebrew/lib/danger/Danger.swiftmodule
import Danger
^
ERROR: Dangerfile eval failed at Dangerfile.swift
ERROR: Could not get the results JSON file at /var/folders/f2/dngvlrg54f968wxfzlqv0k7r0000gp/T/danger-response.json
Error: TypeError: Cannot read property 'metadata' of undefined
at apiForDSL (/snapshot/danger-js/distribution/runner/jsonToDSL.js:119:78)
at Object.<anonymous> (/snapshot/danger-js/distribution/runner/jsonToDSL.js:71:23)
at step (/snapshot/danger-js/distribution/runner/jsonToDSL.js:32:23)
at Object.next (/snapshot/danger-js/distribution/runner/jsonToDSL.js:13:53)
at /snapshot/danger-js/distribution/runner/jsonToDSL.js:7:71
at new Promise (<anonymous>)
at /snapshot/danger-js/distribution/runner/jsonToDSL.js:3:12
at Object.jsonToDSL (/snapshot/danger-js/distribution/runner/jsonToDSL.js:64:53)
at Object.<anonymous> (/snapshot/danger-js/distribution/commands/utils/runDangerSubprocess.js:162:54)
at step (/snapshot/danger-js/distribution/commands/utils/runDangerSubprocess.js:43:23)
```
@dhananjaykumardubey seems that the danger library was compiled in a non compatible way. I don't have an Apple Silicon device to try it, but I think that https://github.com/danger/swift/pull/462 might fix it
@f-meloni I'm down to help test this if you put up a release for it. We have a Silicon machine!
Thank you @morluna, I've released 3.11.1 with this change, let me know if it fixes the issue. @majd already tried the change before the release and it seemed to work
Same problem here when try to install DangerSwift via Package.swift on a local machine, which is not M1 but Intel i7.
Here's the Package.swift file:
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Danger",
// platforms: [.macOS(.v10_15)],
products: [
.library(name: "DangerDeps[DangerLib]",
type: .dynamic,
targets: ["DangerDependencies"]),
],
dependencies: [
.package(url: "https://github.com/danger/swift.git", from: "3.0.0"),
// Danger Plugins
.package(url: "https://github.com/f-meloni/danger-swift-xcodesummary.git", from: "1.2.0"),
.package(url: "https://github.com/f-meloni/danger-swift-coverage.git", from: "1.2.0"),
.package(url: "https://github.com/el-hoshino/DangerSwiftHammer.git", from: "0.1.0"),
],
targets: [
.target(
name: "DangerDependencies",
dependencies: [
.product(name: "danger-swift", package: "swift"),
.product(name: "DangerXCodeSummary", package: "danger-swift-xcodesummary"),
.product(name: "DangerSwiftCoverage", package: "danger-swift-coverage"),
.product(name: "DangerSwiftHammer", package: "DangerSwiftHammer"),
]
),
]
)
And what's even more weird is that on Bitrise it seems able to run, except it can't link modules with an error message below:
/var/folders/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/T/_tmp_dangerfile.swift:3:8: error: no such module 'DangerXCodeSummary'
import DangerXCodeSummary
Yah.. get this in Xcode Cloud builds too:
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
from our ci_post_clone
brew install danger/tap/danger-swift