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 13 Beta/Swift 5.5 - Unable to Run Hooks #45

Closed
leogdion opened this issue Aug 12, 2021 · 20 comments
Closed

Xcode 13 Beta/Swift 5.5 - Unable to Run Hooks #45

leogdion opened this issue Aug 12, 2021 · 20 comments

Comments

@leogdion
Copy link
Contributor

Getting the following error when using Xcode 13/Swift 5.5 build:

[0/0] Build complete!
Package.swift:3:8: error: no such module 'PackageDescription'
import PackageDescription
       ^
Swift/ErrorType.swift:200: Fatal error: Error raised at top level: PackageConfig.Error(reason: "Could not find a file at /var/folders/_z/7dqmnmzj0k1_57ctrgqrdq840000gn/T/package-config - something went wrong with compilation step probably")
[1]    43747 trace trap  swift run komondor run pre-commit
@leogdion
Copy link
Contributor Author

It seems like after PackageConfig run swiftc the JSON file is missing. If I add the SDK flag it compiles correctly but still no JSON file.

/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --driver-mode=swift -L /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4_2 -I /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4_2 -lPackageDescription -package-description-version 4.2 -L .build/debug -I .build/debug -lPackageConfig -L .build/debug -I .build/debug -lExampleConfig -suppress-warnings -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk Package.swift

@patosullivan
Copy link

I'm seeing the same issue with Xcode 13 Beta/Swift 5.5

@bspinner
Copy link

bspinner commented Sep 22, 2021

Issue persists with stable releases of Xcode 13/Swift 5.5

$ swift run komondor install
[0/0] Build complete!
[Komondor] git-hooks installed

$ swift run komondor run
[0/0] Build complete!
Package.swift:4:8: error: no such module 'PackageDescription'
import PackageDescription
       ^
Swift/ErrorType.swift:200: Fatal error: Error raised at top level: PackageConfig.Error(reason: "Could not find a file at /var/folders/fk/g__tsdkd6sz8msb3qn2709t1t9x9bb/T/package-config - something went wrong with compilation step probably")
[1]    19363 illegal hardware instruction  swift run komondor run

@minuscorp
Copy link
Collaborator

Facing same issue, some insights to fix the issue?

@minuscorp
Copy link
Collaborator

Hopefully shibapm/PackageConfig#21 fixes this 😄

@orta
Copy link
Member

orta commented Sep 28, 2021

https://github.com/shibapm/Komondor/releases/tag/1.1.1 should hopefully be the fixed release 👍🏻 - nice work @minuscorp

@minuscorp
Copy link
Collaborator

Please follow-up this issue because it seems to be compiling fine but not generating the json file correctly cc @leogdion

@leogdion
Copy link
Contributor Author

I'll take a look

@leogdion
Copy link
Contributor Author

Getting the same error @orta @minuscorp

Package.swift:4:8: error: no such module 'PackageDescription'
import PackageDescription
       ^
Swift/ErrorType.swift:200: Fatal error: Error raised at top level: PackageConfig.Error(reason: "Could not find a file at /var/folders/jw/kbq06461631982bxccgctpqm0000gn/T/package-config - something went wrong with compilation step probably")
.git/hooks/pre-commit: line 21: 47319 Illegal instruction: 4  $komondor run pre-commit **$gitParams**

@minuscorp
Copy link
Collaborator

minuscorp commented Sep 28, 2021

Make sure you've deleted your .build folder before, although this time is not a compilation issue but a json writing one, must take a deeper look into it, any help is appreciated.

@leogdion
Copy link
Contributor Author

Not sure if these notes belong here or in PackageConfig, but here's what I am getting then running through the debugger:

➜  PackageConfig git:(master) ✗ swift build; DEBUG="*" swift run package-config-example
/Users/leo/Documents/Projects/PackageConfig/Sources/PackageConfigs/PackageConfigs.swift:32:1: error: expressions are not allowed at the top level
ExampleConfig(value: "example value").write()
^
/Users/leo/Documents/Projects/PackageConfig/Sources/PackageConfigs/PackageConfigs.swift:38:1: error: expressions are not allowed at the top level
PackageConfiguration(["example": [
^
/Users/leo/Documents/Projects/PackageConfig/Sources/PackageConfigs/PackageConfigs.swift:5:8: error: no such module 'PackageDescription'
import PackageDescription
       ^
[1/3] Compiling PackageConfigs PackageConfigs.swift
[3/3] Build complete!
CMD: /usr/bin/xcrun --find swiftc
Using SPM version: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4_2
CMD: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --driver-mode=swift -L /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4_2 -I /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4_2 -lPackageDescription -package-description-version 4.2 -L .build/debug -I .build/debug -lPackageConfig -L .build/debug -I .build/debug -lExampleConfig -suppress-warnings -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk Package.swift
Finished launching swiftc
Error(reason: "Could not find a file at /var/folders/jw/kbq06461631982bxccgctpqm0000gn/T/example.config.json - something went wrong with compilation step probably")

I'd love to help. I'm just not sure how JSON is exported.

@minuscorp
Copy link
Collaborator

error: expressions are not allowed at the top level those errors are pretty clear, for me those expressions are not valid, a let example = Example config(...) is needed now in Swift in the first place.

@leogdion
Copy link
Contributor Author

I am just following the example in PackageConfig

@kirillsh
Copy link

On the latest version 1.1.1 I'm still getting the issue while trying to run under xcode13, what am I doing wrong? (tried resetting spm caches, deleting .build folder completely):

DEBUG=* swift run komondor run
[0/0] Build complete!
Setting up .git-hooks for Komondor (v1.0.0)
CMD: /usr/bin/xcrun --find swiftc
Using SPM version: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4_2
CMD: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --driver-mode=swift -L /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4_2 -I /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4_2 -lPackageDescription -package-description-version 5.4 -L .build/debug -I .build/debug -lPackageConfig -suppress-warnings Package.swift
Finished launching swiftc
Swift/ErrorType.swift:200: Fatal error: Error raised at top level: PackageConfig.Error(reason: "Could not find a file at /var/folders/l0/dvxwt04n2r77cyjl5qj2cylw0000gn/T/package-config - something went wrong with compilation step probably")
[1]    5116 illegal hardware instruction  DEBUG=* swift run komondor run

@minuscorp
Copy link
Collaborator

The issue is just as easy as hard. I'll try to explain to see if somebody can throw some help:
1.- In Xcode 12 debugging the binary confirms that linking the ExampleConfig.dylib does help to link the ExampleConfig library so the canImport(ExampleConfig) is true at the time is executed, so write() is called and the file is created.
2.- The same code in Xcode 13 while debugging, confirms that the command does not make canImport(ExampleConfig) to true so the write() method is never called and thus, the file is never found afterwards.

The Xcode 13 command is:

/Applications/Xcode-13.0.0-Release.Candidate.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --driver-mode=swift -L /Applications/Xcode-13.0.0-Release.Candidate.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4_2 -I /Applications/Xcode-13.0.0-Release.Candidate.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4_2 -lPackageDescription -package-description-version 4.2 -L .build/debug -I .build/debug -lPackageConfig -L .build/debug -I .build/debug -lPackageConfig -L .build/debug -I .build/debug -lExampleConfig -sdk /Applications/Xcode-13.0.0-Release.Candidate.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk Package.swift

links ExampleConfig library dynamically as far as I know (besides breaking changes?) and works just fine (changing the toolchain of course) with Swift 5.4.3.

Any ideas?

@minuscorp
Copy link
Collaborator

You might try this https://github.com/minuscorp/PackageConfig/tree/xcode-13-swift-5-5 to test that it correctly works. Don't forget to clean your .build folder before proceed.

@orta
Copy link
Member

orta commented Sep 29, 2021

I've shipped a new release of pcakageconfig (thanks @minuscorp) - the versioning in Komondor should allow just updating that, which could fix it

@leogdion
Copy link
Contributor Author

leogdion commented Sep 29, 2021

I think that worked! 🥳
I'll get a pull request out for the Komondor Package.swift fix out as soon as I double-check.
Thanks @minuscorp for the lesson

@leogdion
Copy link
Contributor Author

Posted at #47
@orta Does Rocket need to be updated as well? I can move forward with that if so.

@orta
Copy link
Member

orta commented Sep 30, 2021

nope, there's no need to update those, their package specifiers will accommodate the patch - should be good to go

@orta orta closed this as completed Sep 30, 2021
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

6 participants