Skip to content

OSError: EOF when trying to run example code on Windows #505

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

Closed
Toqozz opened this issue Apr 11, 2022 · 11 comments · Fixed by #543
Closed

OSError: EOF when trying to run example code on Windows #505

Toqozz opened this issue Apr 11, 2022 · 11 comments · Fixed by #543
Labels

Comments

@Toqozz
Copy link

Toqozz commented Apr 11, 2022

I'm trying to run the example code on the main page of the README, namely:

>>> from pynvim import attach
>>> nvim = attach('child', argv=["/bin/env", "nvim", "--embed", "--headless"])

But I get an error instead:

>>> from pynvim import attach
>>> nvim = attach('child', argv=['C:\\Users\\Toqoz\\Documents\\code\\neovim-test\\Neovim2\\bin\\nvim.exe', '--embed', '--headless'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Toqoz\AppData\Roaming\Python\Python39\site-packages\pynvim\__init__.py", line 122, in attach
    return Nvim.from_session(session).with_decode(decode)
  File "C:\Users\Toqoz\AppData\Roaming\Python\Python39\site-packages\pynvim\api\nvim.py", line 80, in from_session
    channel_id, metadata = session.request(b'nvim_get_api_info')
  File "C:\Users\Toqoz\AppData\Roaming\Python\Python39\site-packages\pynvim\msgpack_rpc\session.py", line 98, in request
    raise OSError('EOF')
OSError: EOF

Running the same thing from a script gives a bit more info, but I think it's irrelevant:

Traceback (most recent call last):
  File "C:\Users\Toqoz\Documents\code\neovim-test\something.py", line 4, in <module>
    nvim = attach('child', argv=['C:\\Users\\Toqoz\\Documents\\code\\neovim-test\\Neovim2\\bin\\nvim.exe', "--embed"])
  File "C:\Users\Toqoz\AppData\Roaming\Python\Python39\site-packages\pynvim\__init__.py", line 122, in attach
    return Nvim.from_session(session).with_decode(decode)
  File "C:\Users\Toqoz\AppData\Roaming\Python\Python39\site-packages\pynvim\api\nvim.py", line 80, in from_session
    channel_id, metadata = session.request(b'nvim_get_api_info')
  File "C:\Users\Toqoz\AppData\Roaming\Python\Python39\site-packages\pynvim\msgpack_rpc\session.py", line 98, in request
    raise OSError('EOF')
OSError: EOF
Exception ignored in: <function BaseSubprocessTransport.__del__ at 0x00000254C7607D30>
Traceback (most recent call last):
  File "C:\Users\Toqoz\AppData\Local\Programs\Python\Python39\lib\asyncio\base_subprocess.py", line 126, in __del__
  File "C:\Users\Toqoz\AppData\Local\Programs\Python\Python39\lib\asyncio\base_subprocess.py", line 104, in close
  File "C:\Users\Toqoz\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close
  File "C:\Users\Toqoz\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
  File "C:\Users\Toqoz\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000254C7637670>
Traceback (most recent call last):
  File "C:\Users\Toqoz\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 115, in __del__
  File "C:\Users\Toqoz\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 79, in __repr__
  File "C:\Users\Toqoz\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_utils.py", line 102, in fileno
ValueError: I/O operation on closed pipe

Any pointers? I've also tried connecting using a socket but that also behaves weirdly on Windows.

$ python -- version
Python 3.9.6
@Shougo
Copy link
Contributor

Shougo commented Apr 11, 2022

The neovim is already running? I think it is not running.

@Toqozz
Copy link
Author

Toqozz commented Apr 12, 2022

I thought the purpose of this code was to launch neovim as a child process and attach to that.

If I launch neovim (externally, just by running it) and then run the code I get the same error.

@Shougo
Copy link
Contributor

Shougo commented Apr 12, 2022

The backslash escape is needed in single quotes?

@Toqozz
Copy link
Author

Toqozz commented Apr 12, 2022

Seems like it...

  File "C:\Users\Toqoz\Documents\code\neovim-test\something.py", line 4
    nvim = attach('child', argv=['C:\Users\Toqoz\Documents\code\neovim-test\Neovim2\bin\nvim.exe', "--embed"])
                                                                                                 ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

I'm fairly sure it is finding nvim.exe since if you change the path you get a file not found error.

@Shougo
Copy link
Contributor

Shougo commented Apr 12, 2022

Hm. You should enable log.

@Shougo
Copy link
Contributor

Shougo commented Apr 17, 2022

Reproduced it on neovim 0.7 Windows version. It works on older neovim(0.5) or Linux neovim.
So I think something is changed.

Unfortunately, pynvim is not maintained well. neovim maintainers want to use Lua language instead.

Note: if_python3 works well.

@Toqozz
Copy link
Author

Toqozz commented Apr 17, 2022

Ah, thanks for that. I'll look into getting something else working.

@MacKinley
Copy link

neovim 0.4.4 was the latest version I was able to pynvim to work well with. For context, I'm on windows trying to use the ActualVim plugin on Sublime Text 4.

@kuripa
Copy link

kuripa commented Mar 25, 2023

Any updates on this? Tried it using Neovim 0.9.0 but still doesnt work..

@justinmk
Copy link
Member

Since CI (github actions) is online now, Windows CI jobs are showing similar failures (python 3.10, 3.11) :

test/test_buffer.py::test_options ERROR                                  [ 10%]
  Exception ignored in: <function BaseSubprocessTransport.__del__ at 0x0000026941A645E0>
  Traceback (most recent call last):
    File "C:\hostedtoolcache\windows\Python\3.11.4\x64\Lib\asyncio\base_subprocess.py", line 126, in __del__
      self.close()
    File "C:\hostedtoolcache\windows\Python\3.11.4\x64\Lib\asyncio\base_subprocess.py", line 104, in close
      proto.pipe.close()
    File "C:\hostedtoolcache\windows\Python\3.11.4\x64\Lib\asyncio\proactor_events.py", line 109, in close
      self._loop.call_soon(self._call_connection_lost, None)
    File "C:\hostedtoolcache\windows\Python\3.11.4\x64\Lib\asyncio\base_events.py", line 761, in call_soon
      self._check_closed()
    File "C:\hostedtoolcache\windows\Python\3.11.4\x64\Lib\asyncio\base_events.py", line [51](https://github.com/neovim/pynvim/actions/runs/5559406058/jobs/10155486134#step:8:52)9, in _check_closed
  Error:     raise RuntimeError('Event loop is closed')

@justinmk justinmk added the bug label Jul 15, 2023
wookayin added a commit to wookayin/pynvim that referenced this issue Oct 15, 2023
Problem: An EOF error happens when creating a subprocess Nvim instance
on Windows. All CI tests are failing, and `attach('child', ...)` cannot
be run

Solution: Ignore pipe_connection_lost error, and do not close the
asyncio event loop. Since embedded nvim only expects to use stdin and
stdout only as a msgpack-RPC channel, it's fine to ignore broken pipes
on the stderr.

Fixes neovim#505
wookayin added a commit to wookayin/pynvim that referenced this issue Oct 15, 2023
Problem: An EOF error happens when creating a subprocess Nvim instance
on Windows. All CI tests are failing, and `attach('child', ...)` cannot
be run.

Solution: Ignore pipe_connection_lost error, and do not close the
asyncio event loop. Since embedded nvim only expects to use stdin and
stdout only as a msgpack-RPC channel, it's fine to ignore broken pipes
on the stderr.

Fixes neovim#505
wookayin added a commit to wookayin/pynvim that referenced this issue Oct 15, 2023
Problem: An EOF error happens when creating a subprocess Nvim instance
on Windows. All CI tests are failing, and `attach('child', ...)` cannot
be run.

Solution: Ignore pipe_connection_lost error, and do not close the
asyncio event loop. Since embedded nvim only expects to use stdin and
stdout only as a msgpack-RPC channel, it's fine to ignore broken pipes
on the stderr.

Fixes neovim#505
@wookayin
Copy link
Member

wookayin commented Oct 15, 2023

neovim/neovim@c86d5fa (#11390) seems to be the culprit: stderr gets closed immediately and this causes the event loop to stop. See PR #543 for the fix.

wookayin added a commit to wookayin/pynvim that referenced this issue Oct 15, 2023
Problem: An EOF error happens when creating a subprocess Nvim instance
on Windows. All CI tests are failing, and `attach('child', ...)` cannot
be run.

Solution: Ignore pipe_connection_lost error, and do not close the
asyncio event loop. Since embedded nvim only expects to use stdin and
stdout only as a msgpack-RPC channel, it's fine to ignore broken pipes
on the stderr.

Fixes neovim#505
wookayin added a commit to wookayin/pynvim that referenced this issue Oct 15, 2023
Problem: An EOF error happens when creating a subprocess Nvim instance
on Windows. All CI tests are failing, and `attach('child', ...)` cannot
be run.

Solution: Ignore pipe_connection_lost error, and do not close the
asyncio event loop. Since embedded nvim only expects to use stdin and
stdout only as a msgpack-RPC channel, it's fine to ignore broken pipes
on the stderr.

Fixes neovim#505
wookayin added a commit to wookayin/pynvim that referenced this issue Oct 15, 2023
Problem: An EOF error happens when creating a subprocess Nvim instance
on Windows. All CI tests are failing, and `attach('child', ...)` cannot
be run.

Solution: Ignore pipe_connection_lost error, and do not close the
asyncio event loop. Since embedded nvim only expects to use stdin and
stdout only as a msgpack-RPC channel, it's fine to ignore broken pipes
on the stderr.

Fixes neovim#505
wookayin added a commit to wookayin/pynvim that referenced this issue Oct 15, 2023
Problem: An EOF error happens when creating a subprocess Nvim instance
on Windows. All CI tests are failing, and `attach('child', ...)` cannot
be run.

Solution: Ignore pipe_connection_lost error, and do not close the
asyncio event loop. Since embedded nvim only expects to use stdin and
stdout only as a msgpack-RPC channel, it's fine to ignore broken pipes
on the stderr.

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

Successfully merging a pull request may close this issue.

6 participants