Hi all, I'm working on some Linux bugfixes for an open source project: SwagGen. It mostly just needs filenames to be capitalized corrrectly, but I've run into what looks like some strange behaviour in the swift run.
I'm running this in swift-latest in Docker, on a shared filesystem on macOS 11.6.
This command (in Docker) gives an error message:
# swift run swaggen generate Specs/Petstore/spec.yml --destination out
error: encountered an I/O error while reading /Users/iain/src/SwagGen/out
However, if I run the binary directly it works fine:
# `swift build --show-bin-path`/swaggen generate Specs/Petstore/spec.yml --destination out
Loading spec from file:///Users/iain/src/SwagGen/Specs/Petstore/spec.yml
Loaded spec: "Swagger Petstore" - 4 operations, 3 definitions, 2 security definitions
Loaded template: 18 template files, 19 options
Destination: /Users/iain/src/SwagGen/out
Generation complete: 22 unchanged
But, if I omit the --destination flag, swift run works!
# swift run swaggen generate Specs/Petstore/spec.yml
[0/0] Build complete!
Loading spec from file:///Users/iain/src/SwagGen/Specs/Petstore/spec.yml
Loaded spec: "Swagger Petstore" - 4 operations, 3 definitions, 2 security definitions
Loaded template: 18 template files, 19 options
Destination: /Users/iain/src/SwagGen/generated
Generation complete: 22 created
I think the error occurs here:
let destinationPath = destination.value.flatMap { Path($0) } ?? (Path.current + "generated")
It's using PathKit which doesn't seem to be doing anything untoward (all of PathKit's own tests work fine on Linux).
Is there something unusual about file: pathnames on Linux, and/or the swift run environment?
Also, are there any docs on how swift run works? I explored the CLI and the Swift website a bit but couldn't find any detail.
Any advice appreciated,
Iain