swift-sh
swift-sh copied to clipboard
error: The operation couldn’t be completed. (NSPOSIXErrorDomain.13)
I consistently get this trying to run even a trivial script like the following. Running it without the sh
works fine. swift-sh 2.4.0
is installed. I'm running Swift 5.7.2 on a M1 Mac with macOS 12.6.1. Not really sure how to troubleshoot further.
#!/usr/bin/swift sh
print("foo")
how'd you install swift sh?
brew install swift-sh
❯ which swift-sh
/opt/homebrew/bin/swift-sh
Thanks for the report, I really don’t have time to debug this and nothing comes to mind. It could be Swift 5.7 doesn't work. /cc @wti
Your script works for me on Intel macOS 13.1 with Swift 5.7.1 installed via homebrew. I also tried #!/usr/bin/env swift-sh
.
To isolate and make a reproducible case, you could start by cloning the project and running the tests
git clone https://github.com/mxcl/swift-sh.git
swift test
Well this is kind of crazy, but it seems to be a side effect of the directory I was running it from. I did the following:
- Cloned swift-sh, ran tests. Success.
- In that directory, created my test script, ran it. Success.
- Went back to directory I was in when I reported the issue (~/Downloads), ran my test script. Failed.
- Copied that test script to my home directory, ran it. Success.
- Copied the test script from step 1 to ~/Downloads, ran it. Failed.
So I'll keep playing around to see if the problem arises again. If getting to the bottom of this is something you want to pursue, I'm happy to run additional tests.
K this is a bug in that the CWD shouldn't cause failure.