On Swift 5.10 swift run --repl worked just fine, but with Swift 6 even in a completely empty SwiftPM project, if I have certain packages in my dependencies array in Package.swift, running swift run --repl and then typing let a = 1 into the REPL gives me this (ignore the spurious warning about empty dSYM file, it's due to the package being, well, empty):
1> let a = 1
warning: (arm64) /Users/myusername/Documents/Programming/swift/problem-package/.build/arm64-apple-macosx/debug/libproblem-package__REPL.dylib empty dSYM file detected, dSYM was created with an executable with no debug info.
a: Int = <extracting data from value failed>
couldn't IRGen expression: Clang importer error
error: /Users/myusername/Documents/Programming/swift/problem-package/.build/arm64-apple-macosx/debug/ArgumentParserToolInfo.build/module.modulemap:1:8: redefinition of module 'ArgumentParserToolInfo'
module ArgumentParserToolInfo {
^
error: /Users/myusername/Documents/Programming/swift/problem-package/.build/arm64-apple-macosx/debug/ArgumentParser.build/module.modulemap:1:8: redefinition of module 'ArgumentParser'
module ArgumentParser {
^
The exact module redefinition errors vary depending on which package(s) I've got in my dependencies.
Edit: I'll be linking to full swift run --repl -v outputs in just a moment.
Anybody have any idea what's going on here, and how I could fix this?
I've tried
swift package reset && swift package purge-cache
rm -rf ~/Library/Caches/org.swift.swiftpm/
fd --hidden --no-ignore --ignore-case --glob "*modulecache*" /var/folders --exec rm -rf (to clear clang's module cache, based on an answer to this SO question)
cursing
pleading
my system
M3 Max MBP (Mac15,9)
macOS 14.6.1 (23G93)
toolchain from Xcode 16.0 (16A242d):
❯ swift -version
swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
Target: arm64-apple-macosx14.0
❯ swift package --version
Swift Package Manager - Swift 6.0.0-dev
steps to reproduce
mkdir problem-package && cd problem-package
swift package init --type=library --disable-xctest --disable-swift-testing
run one of:
swift package add-dependency https://github.com/apple/swift-argument-parser --from 1.3.0
swift package add-dependency https://github.com/pointfreeco/swift-parsing --branch main
swift package add-dependency https://github.com/ordo-one/package-benchmark --from 1.4.0
swift run --repl
let a = 1
:swift-healthcheck output with the swift-argument-parser dependency
output
==== LLDB swift-healthcheck log. ===
This file contains the configuration of LLDB's embedded Swift compiler to help diagnosing module import and search path issues. The swift-healthcheck command is meant to be run *after* an error has occurred.
lldb-1600.0.36.3
Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
SwiftASTContextForExpressions Clang error: /Users/m/Documents/Programming/swift/problem-package/.build/arm64-apple-macosx/debug/ArgumentParserToolInfo.build/module.modulemap:1:8: error: redefinition of module 'ArgumentParserToolInfo'
module ArgumentParserToolInfo {
^
SwiftASTContextForExpressions Clang error: /Users/myusername/Documents/Programming/swift/problem-package/.build/arm64-apple-macosx/debug/ArgumentParser.build/module.modulemap:1:8: error: redefinition of module 'ArgumentParser'
module ArgumentParser {
^
SwiftASTContextForExpressions::LogConfiguration(SwiftASTContext*)0x128037ae0:
SwiftASTContextForExpressions::LogConfiguration() -- Swift/C++ interop : off
SwiftASTContextForExpressions::LogConfiguration() -- Swift/Objective-C interop : on
SwiftASTContextForExpressions::LogConfiguration() -- Architecture : arm64-apple-macosx14.6.1
SwiftASTContextForExpressions::LogConfiguration() -- SDK path : /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk
SwiftASTContextForExpressions::LogConfiguration() -- Runtime resource path : /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift
SwiftASTContextForExpressions::LogConfiguration() -- Runtime library paths : (2 items)
SwiftASTContextForExpressions::LogConfiguration() -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx
SwiftASTContextForExpressions::LogConfiguration() -- /usr/lib/swift
SwiftASTContextForExpressions::LogConfiguration() -- Runtime library import paths : (2 items)
SwiftASTContextForExpressions::LogConfiguration() -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx
SwiftASTContextForExpressions::LogConfiguration() -- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/lib/swift
SwiftASTContextForExpressions::LogConfiguration() -- Framework search paths : (0 items)
SwiftASTContextForExpressions::LogConfiguration() -- Import search paths : (1 items)
SwiftASTContextForExpressions::LogConfiguration() -- /Users/myusername/Documents/Programming/swift/problem-package/.build/arm64-apple-macosx/debug
SwiftASTContextForExpressions::LogConfiguration() -- Extra clang arguments : (0 items)
SwiftASTContextForExpressions::LogConfiguration() -- Plugin search options : (5 items)
SwiftASTContextForExpressions::LogConfiguration() -- -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server
SwiftASTContextForExpressions::LogConfiguration() -- -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server
SwiftASTContextForExpressions::LogConfiguration() -- -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins
SwiftASTContextForExpressions::LogConfiguration() -- -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins
SwiftASTContextForExpressions::LogConfiguration() -- -external-plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-plugin-server