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

Xcode 12.2 Error: "illegal hardware instruction swift run komondor run" and "Illegal instruction: 4 $komondor run pre-commit $gitParams" #39

Open
mhays118 opened this issue Dec 10, 2020 · 4 comments

Comments

@mhays118
Copy link

Hello,

I am trying to integrate Komondor into the codebases I work on. After setting it up, I started getting illegal instruction errors from Komondor and am unable to get it to run in any project.

This happens both when a git-hook runs:
git commit -m "test"

Fatal error: Error raised at top level: PackageConfig.Error(reason: "Could not find a file at /var/folders/nh/x1j0l91x28z35srsgltt4scc0000gn/T/package-config - something went wrong with compilation step probably"): file /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-1103.8.25.8/swift/stdlib/public/core/ErrorType.swift, line 200
.git/hooks/pre-commit: line 21: 80427 Illegal instruction: 4  $komondor run pre-commit $gitParams

or when I manually try running:
swift run komondor run

Fatal error: Error raised at top level: PackageConfig.Error(reason: "Could not find a file at /var/folders/nh/x1j0l91x28z35srsgltt4scc0000gn/T/package-config - something went wrong with compilation step probably"): file /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-1103.8.25.8/swift/stdlib/public/core/ErrorType.swift, line 200
[1]    68843 illegal hardware instruction  swift run komondor run

Reproduction steps:

mkdir TestKomondorPackage  
cd TestKomondorPackage 

swift package init --type library
git init

The package builids and runs.
swift Build

[2/2] Merging module TestKomondorPackage

swift test

[4/4] Linking TestKomondorPackagePackageTests
Test Suite 'All tests' started at 2020-12-09 18:44:51.287
Test Suite 'TestKomondorPackagePackageTests.xctest' started at 2020-12-09 18:44:51.287
Test Suite 'TestKomondorPackageTests' started at 2020-12-09 18:44:51.288
Test Case '-[TestKomondorPackageTests.TestKomondorPackageTests testExample]' started.
Test Case '-[TestKomondorPackageTests.TestKomondorPackageTests testExample]' passed (0.062 seconds).
Test Suite 'TestKomondorPackageTests' passed at 2020-12-09 18:44:51.349.
	 Executed 1 test, with 0 failures (0 unexpected) in 0.062 (0.062) seconds
Test Suite 'TestKomondorPackagePackageTests.xctest' passed at 2020-12-09 18:44:51.349.
	 Executed 1 test, with 0 failures (0 unexpected) in 0.062 (0.062) seconds
Test Suite 'All tests' passed at 2020-12-09 18:44:51.349.
	 Executed 1 test, with 0 failures (0 unexpected) in 0.062 (0.063) seconds

I then modified the package.swift file to the following:

// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "TestKomondorPackage",
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "TestKomondorPackage",
            targets: ["TestKomondorPackage"]),
    ],
    dependencies: [
       .package(url: "https://github.com/shibapm/Komondor.git", from: "1.0.0"),
    ],
    targets: [
        .target(
            name: "TestKomondorPackage",
            dependencies: []),
        .testTarget(
            name: "TestKomondorPackageTests",
            dependencies: ["TestKomondorPackage"]),
    ]
)

#if canImport(PackageConfig)
    import PackageConfig

    let config = PackageConfiguration([
        "komondor": [
            "pre-commit": "swift test",
            "pre-push": "swift test"
        ],
    ])
#endif

run swift run komondor install

Fetching https://github.com/shibapm/Komondor.git
Fetching https://github.com/shibapm/PackageConfig.git
Fetching https://github.com/JohnSundell/ShellOut.git
Cloning https://github.com/shibapm/PackageConfig.git
Resolving https://github.com/shibapm/PackageConfig.git at 0.13.0
Cloning https://github.com/JohnSundell/ShellOut.git
Resolving https://github.com/JohnSundell/ShellOut.git at 2.3.0
Cloning https://github.com/shibapm/Komondor.git
Resolving https://github.com/shibapm/Komondor.git at 1.0.6
/Users/mhays118/tmp/TestKomondorPackage/.build/checkouts/PackageConfig/Sources/PackageConfig/DynamicLibraries.swift:46:37: warning: 'encodedOffset' is deprecated: encodedOffset has been deprecated as most common usage is incorrect. Use utf16Offset(in:) to achieve the same behavior.
                                return String($0.prefix(comment.encodedOffset))
                                                                ^
[21/21] Linking komondor
[Komondor] git-hooks installed

Now, I get either of the errors I mentioned above.

Environment Details:

macOS: Catalina 10.15.7 (19H15)
Swift: Apple Swift version 5.3.1 (swiftlang-1200.0.41 clang-1200.0.32.8) Target: x86_64-apple-darwin19.6.0
Xcode: Version 12.2 (12B45b)
git: 2.28.0

Attempted workarounds

Similar issues

This is similar to #28, however, the solution presented ##28 (comment), doesn't seem to work.

I've tried running the solution from that PR multiple times, same issue.

swift package reset
swift run komondor install
swift run komondor run

Tried multiple versions of Komondor

Komondor versions tested: 1.0.6, 1.05, 1.04.

All three of these versions have the same issue.

Changing the swift-tools-version

I've tried changing the swift-tools-version in package.swift to 5.3, 5.1, and 4.2.

Same issue with all these tool versions.

@anibalrodriguez
Copy link

Hey @mhays118, Had the same issue yesterday, fixed by adding write() to the PackageConfiguration

E.g:

let config = PackageConfiguration([ "komondor": [ "pre-commit": [ ... ], ], ]).write()

@otidad
Copy link

otidad commented Oct 5, 2021

Hey @mhays118, Had the same issue yesterday, fixed by adding write() to the PackageConfiguration

E.g:

let config = PackageConfiguration([ "komondor": [ "pre-commit": [ ... ], ], ]).write()

I updated Xcode to 13.0 and have the same issue mentioned in original post but my PackageConfiguration already has .write().

Is there any other solution I can try??

@cerupcat
Copy link

cerupcat commented Nov 8, 2021

I also already have .write() as part of the PackageConfiguration.

Any other ideas how to fix this?

@Marquis103
Copy link

Same...not working for me either...already have .write(). using swift-tools 5.4

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

5 participants