6

I have an SSH connection from a Windows machine to another, and then trying to do a poetry install.

My problem is: I get this error when executing poetry install through ssh:

[WinError 1312] A specified logon session does not exist. It may already have been terminated.

This command works perfectly when I execute it locally on the target machine, but fails when connecting through ssh.

How can I get rid/fix the [WinError 1312]?

I saw another user that posted the same question recently, but removed it.

I've seen some clues regarding the MachineKeys, but have really no idea on how to proceed. Any suggestion will be highly appreciated.


Python: 3.10.8

Poetry: 1.2.1

Installing dependencies from lock file

Package operations: 5 installs, 0 updates, 0 removals

  • Installing install-requires (0.3.0)

  OSError

  [WinError 1312] A specified logon session does not exist. It may already have been terminated.

  at ~\AppData\Roaming\pypoetry\venv\lib\site-packages\win32ctypes\core\ctypes\_util.py:53 in check_zero
       49│
       50│ def check_zero_factory(function_name=None):
       51│     def check_zero(result, function, arguments, *args):
       52│         if result == 0:
    →  53│             raise make_error(function, function_name)
       54│         return result
       55│     return check_zero
       56│
       57│

The following error occurred when trying to handle this error:


  error

  (1312, 'CredRead', 'A specified logon session does not exist. It may already have been terminated.')

  at ~\AppData\Roaming\pypoetry\venv\lib\site-packages\win32ctypes\pywin32\pywintypes.py:37 in pywin32error
       33│ def pywin32error():
       34│     try:
       35│         yield
       36│     except WindowsError as exception:
    →  37│         raise error(exception.winerror, exception.function, exception.strerror)
       38│
Xiddoc
  • 3,369
  • 3
  • 11
  • 37
suecanna
  • 63
  • 4
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – user11717481 Nov 10 '22 at 16:42
  • Clarified, thanks for the heads up @ellhe-blaster. – suecanna Nov 16 '22 at 16:53
  • i have the same issue on Windows Home. Works correctly on a local session, but fails with 1312 over ssh for both Command and Powershell ssh sessions. Have tried the disable option in "Network access: Do not allow storage of passwords and credentials for network authentication" with gpedit.msc without success. – miguelv Dec 30 '22 at 13:20
  • Are you sure this is the full stack trace? – Xiddoc Jan 01 '23 at 07:09

1 Answers1

2

Based on similarities in the stack traces and your description, my guess is that you're facing the same bug from #1892 and #1917, where Poetry tries to use your keyring to access/publish modules, and hence fails when these credentials are invalid.

But it appears that poetry tries to access the keyring even for install operations.

One of the solutions proposed was to uninstall the keyring package remotely:

For me, I worked around the problem by pip uninstalling the 'keyring' package from that virt env.

Another solution is to export the environment variable PYTHON_KEYRING_BACKEND. Here's an example of how you can do that on Windows:

SET PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring

... and on Linux:

export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring

Unfortunately, it appears that issue #1917 is still open and unresolved, so this is the best workaround that you can find to fix the issue for now.

Xiddoc
  • 3,369
  • 3
  • 11
  • 37
  • 1
    Thanks, I have tried this without success. Error morphs into: `Command C:\...\.venv\Scripts\python.exe -m pip install --disable-pip-version-check --isolated --no- input --prefix C:\...\.venv --no-deps C:\...\AppData\Local\pypoetry\Cache\artifacts\c4\3d\37 \...\ipython-8.7.0-py3-none-any.whl errored with the following return code 101, and output: Unable to create process using... ` – miguelv Jan 06 '23 at 11:22
  • It sounds like your Python venv installation has problems with the PATH (env variables), check [these answers out](https://stackoverflow.com/q/37220055/11985743), maybe they will help :) – Xiddoc Jan 06 '23 at 12:34
  • 1
    Update: the above error appeared to be transient, and with a clean restart+retry it all worked smoothly. Fixed for me! – miguelv Jan 06 '23 at 12:35
  • 1
    It worked for me too, thanks a lot for the workaround!! – suecanna Jan 10 '23 at 15:48