headius/spoon

Error starting rsense in Windows

Closed this issue · 9 comments

Starting rsense in Windows throws:

c:/ruby-2.2.6-x64/lib/ruby/gems/2.2.0/gems/rsense-0.5.18/lib/rsense/client/runner.rb:112:in `start': uninitialized constant Spoon::FileActions (NameError)
	from c:/ruby-2.2.6-x64/lib/ruby/gems/2.2.0/gems/rsense-0.5.18/bin/rsense:12:in `<top (required)>'
	from C:/ruby-2.2.6-x64/bin/rsense:23:in `load'
	from C:/ruby-2.2.6-x64/bin/rsense:23:in `<main>'

I have the same problem in windows 8

Me too. #17 seems related.

having this issue on windows still

I am having this issue too. If you look at windows.rb, it has a completely different interface than unix.rb. Either someone refactored the unix.rb and didn't refactor windows.rb or windows support was never properly added. Ugh.

@headius You should at least consider raising an error in windows.rb to note that this gem doesn't support Windows and maybe ask if someone would like to support it by doing a pull request and give them the github link.

Golly, I never saw this report. Will look into it.

Ok, so the problem here is that rsense is using the posix_spawn "file actions" feature but it's not available on Windows; the file actions would be fed into the posix_spawn function, which also does not exist on Windows.

The only way to fix this would be to try to unpack those actions and map them to Windows CreateProcess arguments, and of course to actually change the process launching to work with CreateProcess instead of spawn. It's not possible to do them with a simple spawn call as in windows.rb today.

The error that @jonyyz would be difficult to provide, because rsense is just going after a class defined in unix.rb that doesn't exist in windows.rb. I could make it a dummy class, but then it would just fail later when rsense tries to call posix_spawn.

I could also just remove Windows support altogether and error out, but the library does a reasonable job of providing the spawn and spawnp part of the interface on Windows.

So, what's a guy to do?

tbh, I think the first thing the probably needs adjusted is your mindset. It sounds to me like you're lamenting the incompleteness of Windows POSIX compliance. To be quite honest, I haven't heard anyone talk about that in quite some time. The open source community in general seems to just take that as a given and many packages and libraries have worked around those issues. It's kind of like how Facebook just accepts that W3 standard support is always behind with web browsers so they used transpiling to work around it because we need things to work today. It's a form of being agile in today's rapidly changing technology landscape and also embracing the diverse ecosystem.

I'm pretty sure a fix is possible because if you look at the documentation for ffi that you are consuming, there should be a way. It's just a matter of implementing the same interface as unix.rb and marshalling the proper calls. Have you attempted to prototype a solution to see how far you can get? I might be able to help if you run into specific issues.

I don't have to time to figure this all out because I work at a very stressful job and I'm actually trying to level up my ruby skills hence it would be nice if we could get autocomplete-ruby to work in atom that depends on rsense which depends on spoon.

You should be able to look at other projects to see how they are doing this and get some ideas or in the worst case scenario hit up some Microsoft MVP's that also have some ruby knowledge. They exist.

Also have you looked this?

https://docs.microsoft.com/en-us/cpp/c-runtime-library/spawn-wspawn-functions?view=vs-2019

As much as it pains me to say it (not much) spoon was never really intended to be a catch-all process launching API for Ruby. I originally released it as a demo of using FFI to call posix_spawn, and then the Windows logic was contributed by another user. I have done some win32 programming in the past, so I could probably expand this implementation to use CreateProcessEx, but there are some other options.

  • The childprocess gem also uses FFI, but is current and well-supported on Windows.
  • Similarly, there's the win32-process gem that provides better Windows process management.

There's also the built-in spawn function but some features won't work on certain Ruby implementation + OS combinations.

rsense could probably use the childprocess gem without too much trouble, but I don't know rsense internals enough to make that change myself. I could also rewire spoon to use childprocess to implement the spawn forms, but rsense failed because it was trying to use posix_spawn directly. So we're back in the same boat... need to map posix_spawn features to something else.

FWIW I'd love to see spoon provide a posix_spawn look-alike on Windows, but it might be simpler to get rsense to switch to childprocess, at this point.

Sorry folks, I'm going to close this. spoon's Windows support was contributed by another user and I'm not planning to do any work on it. Even if I did, the API of spoon doesn't really fit well with using win32 CreateProcess, and I'd have to essentially make a posix_spawn shim layer.

The best option is to get libraries on the childprocess gem, since it works on JRuby and on Windows.