swift-sh icon indicating copy to clipboard operation
swift-sh copied to clipboard

error: The operation couldn’t be completed. (NSPOSIXErrorDomain.13)

Open chrispix opened this issue 2 years ago • 6 comments

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")

chrispix avatar Jan 10 '23 00:01 chrispix

how'd you install swift sh?

mxcl avatar Jan 15 '23 19:01 mxcl

brew install swift-sh

❯ which swift-sh
/opt/homebrew/bin/swift-sh

chrispix avatar Jan 18 '23 05:01 chrispix

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

mxcl avatar Jan 18 '23 11:01 mxcl

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

wti avatar Jan 22 '23 12:01 wti

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:

  1. Cloned swift-sh, ran tests. Success.
  2. In that directory, created my test script, ran it. Success.
  3. Went back to directory I was in when I reported the issue (~/Downloads), ran my test script. Failed.
  4. Copied that test script to my home directory, ran it. Success.
  5. 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.

chrispix avatar Jan 23 '23 20:01 chrispix

K this is a bug in that the CWD shouldn't cause failure.

mxcl avatar Jan 24 '23 14:01 mxcl