`--dir .` and `--dir /` conflict with each other
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 504
- Forks
- 37
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 44
Description
Description
When I run wasmkit run --dir . --dir / <Wasm binary>, it succeeds or fails randomly. When I use --dir .build --dir / or --dir . --dir /Users instead, it always succeeds. So I think --dir . and --dir / conflict with each other.
Steps to reproduce
-
Run
mkdir foo && cd foo -
Run
swift package init --type executable -
Edit
Sources/foo/foo.swiftimport Foundation @main struct foo { static func main() { print(try! String(contentsOf: URL(filePath: #filePath), encoding: .utf8)) print(Bundle.main) } } -
Run
swift build --swift-sdk swift-DEVELOPMENT-SNAPSHOT-2025-10-02-a_wasm -
Run
wasmkit run --dir . --dir / .build/wasm32-unknown-wasip1/debug/foo.wasmseveral times
Expected behavior
It succeeds every time. Or it fails every time with the same error messages.
Actual behavior
It always fails, but its error messages randomly change each time it is executed.
Pattern 1:
import Foundation
@main
struct foo {
static func main() {
print(try! String(contentsOf: URL(filePath: #filePath), encoding: .utf8))
print(Bundle.main)
}
}
Error: Trap: unreachable
0: $s10Foundation6BundleC05_mainB033_6273FB07A96EB35BCC520B3A80F5C3CDLL_WZ
1: swift_once
2: $s10Foundation6BundleC4mainACvgZ
3: $s3fooAAV4mainyyFZ
4: $s3fooAAV5$mainyyFZ
5: main
6: __main_void
7: _start
8: unknown
Pattern 2:
foo/foo.swift:9: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=260 "The file doesn’t exist."UserI
nfo={NSFilePath=/Users/kebo/foo/Sources/foo/foo.swift, NSURL=file:///Users/kebo/foo/Sources/foo/foo.swift, NSUnderlyingError=Error Domain=NSPOSIXErro
rDomain Code=44 "No such file or directory"}
Error: Trap: unreachable
0: $ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF
1: swift_unexpectedError
2: $s3fooAAV4mainyyFZ
3: $s3fooAAV5$mainyyFZ
4: main
5: __main_void
6: _start
7: unknown
Environemnt
$ uname -a
Darwin Xylotrupes-gideon.local 25.1.0 Darwin Kernel Version 25.1.0: Sun Oct 5 21:11:28 PDT 2025; root:xnu-12377.40.120~10/RELEASE_ARM64_T8132 arm64
$ which swift
/Users/kebo/Library/Application Support/swiftly/bin/swift
$ swiftly list
Installed release toolchains
----------------------------
Swift 6.2.0 (default)
Installed snapshot toolchains
-----------------------------
main-snapshot-2025-10-02 (in use)
main-snapshot-2025-09-20
main-snapshot-2025-09-06
$ swift --version
Apple Swift version 6.3-dev (LLVM 0d0246569621d5b, Swift 199240b3fe97eda)
Target: arm64-apple-macosx26.0
Build config: +assertions
$ which wasmkit
/Users/kebo/Library/Application Support/swiftly/bin/wasmkit
$ wasmkit --version
0.1.6
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the shown wasmkit run --dir . --dir / command and the Swift package example. Trace the directory handling used by the wasmkit run entry point, then verify that repeated runs produce consistent behavior and error messages for overlapping directory arguments.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift, wasm
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100