Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on Linux #6

Closed
niklassaers opened this issue Jun 7, 2017 · 10 comments
Closed

Error on Linux #6

niklassaers opened this issue Jun 7, 2017 · 10 comments

Comments

@niklassaers
Copy link
Contributor

With Swift 3.1.1 on Ubuntu, I get the following error:

  • swift test
    Compile Swift Module 'ShellOut' (1 sources)
    /var/lib/jenkins/workspace/ShellOut SPM Linux/Sources/ShellOut.swift:96:60: error: cannot assign to property: 'readabilityHandler' is a get-only property
    outputPipe.fileHandleForReading.readabilityHandler = stdoutHandler
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    /var/lib/jenkins/workspace/ShellOut SPM Linux/Sources/ShellOut.swift:100:59: error: cannot assign to property: 'readabilityHandler' is a get-only property
    errorPipe.fileHandleForReading.readabilityHandler = stderrHandler
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    /var/lib/jenkins/workspace/ShellOut SPM Linux/Sources/ShellOut.swift:108:60: error: cannot assign to property: 'readabilityHandler' is a get-only property
    outputPipe.fileHandleForReading.readabilityHandler = nil
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    /var/lib/jenkins/workspace/ShellOut SPM Linux/Sources/ShellOut.swift:109:59: error: cannot assign to property: 'readabilityHandler' is a get-only property
    errorPipe.fileHandleForReading.readabilityHandler = nil
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    :0: error: build had 1 command failures
@JohnSundell
Copy link
Owner

Thanks for reporting this @niklassaers! I created this PR that should fix the problem 😄 #7

@JohnSundell
Copy link
Owner

@niklassaers It seems like we have some more problems on Linux, all the tests are failing 😅 But if you use the latest released version instead of master, you at least shouldn't have that build error. With WWDC and new Xcode/Swift version to upgrade to, I won't have time to look into the test failures right now. Feel free to take a look if you want, otherwise I'll take care of it within the next few weeks 🙂

@jorgealegre
Copy link

jorgealegre commented Aug 14, 2017

Hi @JohnSundell . Do you know if there's a way around to this readabilityHandler problem on Linux? I know using a NotificationCenter for when data is available to be read is an option.

@JohnSundell
Copy link
Owner

@georgealegre Interesting. Can you tell me more about this approach?

@jorgealegre
Copy link

jorgealegre commented Aug 14, 2017

I have the same issue trying to run a program and reading its output as soon as it's available. It's running on a server thanks to the Kitura framework and the idea is to use websockets to broadcast the output. Using readibiltyHandler works for me on Mac but on Ubuntu I have the same issue as you. You can see my code here: GitHub

I've read on a bunch of SO posts about using notifications and reacting to those notifications but I can't get it to work. The function that should be receiving those notifications is never called. I assume it's an issue with threads but there isn't much info out there.

You can read about the solution I'm talking about here: StackOverflow

Maybe you can get it to work and share some insight with me in the process.

BTW, thanks for your amazing blog posts. I read them every week.

@jorgealegre
Copy link

@JohnSundell I've found the implementation of FileHandle for Foundation on Linux and it seems these things are still not implemented - FileHandle. Seems we have to wait a while. Using notifications won't work either since waitInBackgroundAndNotify() is also not implemented .

@JohnSundell
Copy link
Owner

Thanks for looking into this @georgealegre 👍 Seems like we'll need to revert back to the old technique used before https://github.com/JohnSundell/ShellOut/pull/3/files on Linux. It's also a requirement for using the new version of ShellOut for Marathon, since it also supports Linux - so I'll try to look into this ASAP.

@JohnSundell
Copy link
Owner

I've now worked around the error and merged my PR: #7. ShellOut again works on Linux 🎉 Think this is good enough to close this issue for now, and we can revisit this again once the Swift standard library on Linux has caught up with its macOS equivalent in this regard 🙂 What do you think @georgealegre & @niklassaers?

@jorgealegre
Copy link

Seems ok. I'm not sure what your plans are with ShellOut. From the code I've read, it seems like it isn't meant for using input and output streams without closing the pipes or reading asynchronously. I'm not sure if I'm explaining myself correctly. For example, ShellOut wouldn't be able to run $ tail -f somefile since the STDOUT file would never be closed until the process is terminated. I'm even more screwed with my project 'cause the process I'm launching prompts the user for input while it's running.

@JohnSundell
Copy link
Owner

I would actually love for ShellOut to be able to hand continous/async output, but there's a separate issue for it here: #11. Closing this one for now 😄 Thanks for all your input on this 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants