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

pipenv run suppresses OpenSSH on Windows 10 #3637

Open
MatthewWilkes opened this issue Mar 21, 2019 · 11 comments
Open

pipenv run suppresses OpenSSH on Windows 10 #3637

MatthewWilkes opened this issue Mar 21, 2019 · 11 comments
Labels
OS: Windows This issue affects the Windows Operating System.

Comments

@MatthewWilkes
Copy link

Issue description

Windows 10 supplies OpenSSH as an optional feature. When this is activated the ssh command works as is familiar from POSIX systems. However, any command invoked by pipenv run or the environment found through pipenv shell fail to be able to use this command.

Expected result

The command sequence:
pipenv shell
ssh

should result in the ssh usage prompt on machines with the OpenSSH Client optional feature installed

Actual result

A command not found error is shown.

Steps to replicate

As above, enable OpenSSH server, then you will be unable to run ssh after pipenv shell until you exit the environment.


$ pipenv --support

Pipenv version: '2018.11.26'

Pipenv location: 'C:\\Users\\micro\\AppData\\Roaming\\Python\\Python37\\site-packages\\pipenv'

Python location: 'c:\\users\\micro\\appdata\\local\\programs\\python\\python37-32\\python.exe'

Python installations found:

  • 3.8.0a1: C:\Users\micro\AppData\Local\Programs\Python\Python38\python.exe
  • 3.8.0a1: C:\Users\micro\AppData\Local\Programs\Python\Python38-32\python.exe
  • 3.7.2: C:\Users\micro\AppData\Local\Programs\Python\Python37-32\python.exe

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.7.2',
 'os_name': 'nt',
 'platform_machine': 'AMD64',
 'platform_python_implementation': 'CPython',
 'platform_release': '10',
 'platform_system': 'Windows',
 'platform_version': '10.0.16299',
 'python_full_version': '3.7.2',
 'python_version': '3.7',
 'sys_platform': 'win32'}

System environment variables:

  • ALLUSERSPROFILE
  • APPDATA
  • COMMONPROGRAMFILES
  • COMMONPROGRAMFILES(X86)
  • COMMONPROGRAMW6432
  • COMPUTERNAME
  • COMSPEC
  • FPS_BROWSER_APP_PROFILE_STRING
  • FPS_BROWSER_USER_PROFILE_STRING
  • HOMEDRIVE
  • HOMEPATH
  • LOCALAPPDATA
  • LOGONSERVER
  • NUMBER_OF_PROCESSORS
  • ONEDRIVE
  • OS
  • PATH
  • PATHEXT
  • PROCESSOR_ARCHITECTURE
  • PROCESSOR_ARCHITEW6432
  • PROCESSOR_IDENTIFIER
  • PROCESSOR_LEVEL
  • PROCESSOR_REVISION
  • PROGRAMDATA
  • PROGRAMFILES
  • PROGRAMFILES(X86)
  • PROGRAMW6432
  • PSMODULEPATH
  • PUBLIC
  • SESSIONNAME
  • SYSTEMDRIVE
  • SYSTEMROOT
  • TEMP
  • TMP
  • USERDOMAIN
  • USERDOMAIN_ROAMINGPROFILE
  • USERNAME
  • USERPROFILE
  • WINDIR
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PIP_SHIMS_BASE_MODULE
  • PIP_PYTHON_PATH
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv?specific environment variables:

Debug?specific environment variables:

  • PATH: C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Users\micro\AppData\Roaming\Python\Python37\Scripts\;C:\Windows\System32\OpenSSH\;C:\Windows\System32\OpenSSH;C:\Users\micro\AppData\Local\Programs\Python\Python37-32\Scripts\;C:\Users\micro\AppData\Local\Programs\Python\Python37-32\;C:\Users\micro\AppData\Local\Microsoft\WindowsApps;C:\Users\micro\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\micro\AppData\Roaming\Python\Python37\Scripts;C:\Windows\System32\OpenSSH;

Contents of Pipfile ('C:\Users\micro\Pipfile'):

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]

[requires]
python_version = "3.7"
@MatthewWilkes
Copy link
Author

This happens in both powershell and cmd.exe. In both, activating the virtualenv does not cause this problem. Also, opening a child powershell or cmd in each does not cause this problem.

@MatthewWilkes
Copy link
Author

The issue appears to be in https://github.com/pypa/pipenv/blob/master/pipenv/shells.py#L57-L62

If I try running that function in isolation the problem can be reproduced. If I remove the windows codepath and run the posix codepath in Windows OpenSSH remains available.

@uranusjr
Copy link
Member

uranusjr commented Mar 22, 2019

Works for me.

C:\Users\uranusjr\Documents\programming\pipenv>where ssh
C:\Windows\System32\OpenSSH\ssh.exe

C:\Users\uranusjr\Documents\programming\pipenv>ssh
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-E log_file] [-e escape_char]
           [-F configfile] [-I pkcs11] [-i identity_file]
           [-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec]
           [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address]
           [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
           destination [command]

C:\Users\uranusjr\Documents\programming\pipenv>pipenv run ssh
Loading .env environment variables…
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-E log_file] [-e escape_char]
           [-F configfile] [-I pkcs11] [-i identity_file]
           [-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec]
           [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address]
           [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
           destination [command]

C:\Users\uranusjr\Documents\programming\pipenv>pipenv shell
Loading .env environment variables…
Launching subshell in virtual environment…
Microsoft Windows [Version 10.0.17134.648]
(c) 2018 Microsoft Corporation. All rights reserved.

(.venv) C:\Users\uranusjr\Documents\programming\pipenv>ssh
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-E log_file] [-e escape_char]
           [-F configfile] [-I pkcs11] [-i identity_file]
           [-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec]
           [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address]
           [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
           destination [command]

My guess is you have a problem in how your PATH is set up. It’d be very helpful if you could provide information on your environment, like those listed in the issue template.

@MatthewWilkes
Copy link
Author

@uranusjr I did follow the template, the environment variables were included in the support output, so that's in the original ticket.

I can confirm it is not a PATH issue, as I am unable to cd into C:\Windows\System32\OpenSSH in the sub shell. I'll look in to system versions in case this is a Windows version difference, but can you confirm that is the only location of ssh on your path?

@uranusjr
Copy link
Member

uranusjr commented Mar 22, 2019

can you confirm that is the only location of ssh on your path?

I believe it is (where ssh output attached)


Edit: The fact you cannot cd into OpenSSH is interesting… maybe this is a permission issue?

@MatthewWilkes
Copy link
Author

To confirm the above, and maybe help with reproducing this issue:

Running ssh

C:\Users\micro>ssh
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
        [-D [bind_address:]port] [-E log_file] [-e escape_char]
        [-F configfile] [-I pkcs11] [-i identity_file]
        [-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec]
        [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address]
        [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
        [user@]hostname [command]

C:\Users\micro>pipenv run ssh
'ssh' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\micro>

Running dir

C:\Users\micro>dir c:\Windows\System32\OpenSSH\ssh.exe
Volume in drive C is OS
Volume Serial Number is AEDD-9508

Directory of c:\Windows\System32\OpenSSH

28/09/2017  15:49           851,456 ssh.exe
            1 File(s)        851,456 bytes
            0 Dir(s)  175,094,468,608 bytes free

C:\Users\micro>pipenv run dir c:\Windows\System32\OpenSSH\ssh.exe
The system cannot find the file specified.

C:\Users\micro>

@MatthewWilkes
Copy link
Author

Sorry, I missed the where ssh line. I assume pipenv run where ssh returns the same?

I'm nervous about assuming this a misconfiguration on my end, as this is on a laptop that was bought from a shop in the last month and has been very minimally used. I don't think I've had a chance to mess up its environment.

@MatthewWilkes
Copy link
Author

Okay, some more investigation results this morning.

  1. os.execvp("cmd", ["cmd"]) does not solve the problem, it results in two interleaved command windows, one with ssh working one without.
  2. os.path.exists("c:\Windows\System32\OpenSSH") returns False.

Based on these two, I think this is indeed a permissions issue, and that it's Python that can't see ssh. Given pipenv's architecture I'm not sure this is something you can fix, but I'm still a bit lost as to the root cause, so could be mistaken here.

@uranusjr
Copy link
Member

If it is indeed permission, the question becomes why would a nedtwd shell causes it. Is your current user an admin? Is Pipenv installed in the user domain, or system? (Honestly I am not very sure what could be causing this.)

@MatthewWilkes
Copy link
Author

Indeed, very good questions.

The current user is an admin, the machine came with Windows preinstalled with an admin user called "micro" (honestly, I've not used Windows much so don't know if that's common). Pipenv is installed into user scope in Python 3.7 (so, home\AppData\Roaming\ etc).

I've ensured that the Windows install is fully up-to-date and have tried removing and re-adding the OpenSSH Client, still nothing.

@oz123 oz123 added the OS: Windows This issue affects the Windows Operating System. label Jan 23, 2022
@matteius
Copy link
Member

@MatthewWilkes is this still an issue for you? Have you tried the latest version of pipenv?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS: Windows This issue affects the Windows Operating System.
Projects
None yet
Development

No branches or pull requests

4 participants