pypa / pipenv

Python Development Workflow for Humans.
https://pipenv.pypa.io
MIT License
24.86k stars 1.87k forks source link

Pipenv fails to install a package when non-existent env variables are used in package URL on windows #4655

Open souris4science opened 3 years ago

souris4science commented 3 years ago

Issue description

As mentioned in the documentation, you may inject credentials into the URL of a package as environment variables. But in case these variables do not exist, the user is not prompted for username and password, but instead the operation fails with authentication error. The problem occurred on windows 10 host with Python 3.8.6-64-bit and pipenv 2020.11.15.

Expected result

Non-existent env variables should be replaced with empty strings and a request to https://:@github.com/myaccount/myproject.git would pop-up a window asking the user to provide the username and password.

Actual result

Package installation fails with authentication failure:

>py -3.8-64 -m pipenv install -e "git+https://${GITHUB_USER}:${GITHUB_PASS}@github.com/myaccount/myproject.git#egg=myproject"
Creating a virtualenv for this project...
Pipfile: C:\Users\****\Documents\workspace\tmp\Pipfile
Using C:/Users/****/AppData/Local/Programs/Python/Python38/python.exe (3.8.6) to create virtualenv...
[=   ] Creating virtual environment...created virtual environment CPython3.8.6.final.0-64 in 1062ms
  creator CPython3Windows(dest=C:\Users\****\.virtualenvs\tmp-mTB5Vxym, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\****\AppData\Local\pypa\virtualenv)
    added seed packages: pip==21.0.1, setuptools==54.1.2, wheel==0.36.2
  activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

Successfully created virtual environment!
Virtualenv location: C:\Users\****\.virtualenvs\tmp-mTB5Vxym
Creating a Pipfile for this project...
Installing -e git+https://${GITHUB_USER}:${GITHUB_PASS}@github.com/myaccount/myproject.git#egg=myproject...
Error:  An error occurred while installing -e git+https://${GITHUB_USER}:${GITHUB_PASS}@github.com/myaccount/myproject.git#egg=myproject!
Error text: Obtaining myproject from git+https://%24%7BGITHUB_USER%7D:****@github.com/myaccount/myproject.git#egg=myproject (from -r c:\users\****\appdata\local\temp\pipenv-kzakn_kw-requirements\pipenv-8cxdhqus-requirement.txt (line 1))
  Cloning https://%24%7BGITHUB_USER%7D:****@github.com/myaccount/myproject.git to c:\users\****\.virtualenvs\tmp-mtb5vxym\src\myproject

  Running command git clone -q 'https://%24%7BGITHUB_USER%7D:****@github.com/myaccount/myproject.git' 'C:\Users\****\.virtualenvs\tmp-mTB5Vxym\src\myproject'
  remote: Invalid username or password.
  fatal: Authentication failed for 'https://github.com/myaccount/myproject.git/'
WARNING: Discarding git+https://%24%7BGITHUB_USER%7D:****@github.com/myaccount/myproject.git#egg=myproject. Command errored out with exit status 128: git clone -q 'https://%24%7BGITHUB_USER%7D:****@github.com/myaccount/myproject.git' 'C:\Users\****\.virtualenvs\tmp-mTB5Vxym\src\myproject' Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement myproject (unavailable)
ERROR: No matching distribution found for myproject (unavailable)

Installation Failed

Steps to replicate


On Windows with the env variables GITHUB_USER and GITHUB_PASS unset, run the following on an empty project:

>py -3.8-64 -m pipenv install -e "git+https://${GITHUB_USER}:${GITHUB_PASS}@github.com/myaccount/myproject.git#egg=myproject"

$ pipenv --support Pipenv version: `'2020.11.15'` Pipenv location: `'C:\\Users\\****\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\pipenv'` Python location: `'C:\\Users\\****\\AppData\\Local\\Programs\\Python\\Python38\\python.exe'` Python installations found: - `3.8.6`: `C:\Users\****\AppData\Local\Programs\Python\Python38\python.exe` - `3.7.0`: `C:\Program Files\Python37\python.exe` - `3.7.0`: `C:\Python37-32\python.exe` - `2.7.6`: `C:\Python27\python.exe` PEP 508 Information: ``` {'implementation_name': 'cpython', 'implementation_version': '3.8.6', 'os_name': 'nt', 'platform_machine': 'AMD64', 'platform_python_implementation': 'CPython', 'platform_release': '10', 'platform_system': 'Windows', 'platform_version': '10.0.17763', 'python_full_version': '3.8.6', 'python_version': '3.8', 'sys_platform': 'win32'} ``` System environment variables: - `ALLUSERSPROFILE` - `APPDATA` - `CHOCOLATEYINSTALL` - `CHOCOLATEYLASTPATHUPDATE` - `COMMONPROGRAMFILES` - `COMMONPROGRAMFILES(X86)` - `COMMONPROGRAMW6432` - `COMPUTERNAME` - `COMSPEC` - `DRIVERDATA` - `GIT_LFS_PATH` - `GROOVY_HOME` - `HOMEDRIVE` - `HOMEPATH` - `INTELLIJ IDEA COMMUNITY EDITION` - `LM_LICENSE_FILE` - `LOCALAPPDATA` - `LOGONSERVER` - `NUMBER_OF_PROCESSORS` - `ONEDRIVE` - `ONEDRIVECOMMERCIAL` - `OS` - `PATH` - `PATHEXT` - `PIPENV_MAX_DEPTH` - `PROCESSOR_ARCHITECTURE` - `PROCESSOR_IDENTIFIER` - `PROCESSOR_LEVEL` - `PROCESSOR_REVISION` - `PROG27B48B2C054` - `PROGRAMDATA` - `PROGRAMFILES` - `PROGRAMFILES(X86)` - `PROGRAMW6432` - `PROMPT` - `PSMODULEPATH` - `PUBLIC` - `PYCHARM EDU` - `QT_DEVICE_PIXEL_RATIO` - `REPS` - `SESSIONNAME` - `SYSTEMDRIVE` - `SYSTEMROOT` - `TEMP` - `TMP` - `UATDATA` - `USERDNSDOMAIN` - `USERDOMAIN` - `USERDOMAIN_ROAMINGPROFILE` - `USERNAME` - `USERPROFILE` - `VBOX_MSI_INSTALL_PATH` - `VS110COMNTOOLS` - `VS120COMNTOOLS` - `VS140COMNTOOLS` - `WINDIR` - `PIP_DISABLE_PIP_VERSION_CHECK` - `PYTHONDONTWRITEBYTECODE` - `PIP_SHIMS_BASE_MODULE` - `PIP_PYTHON_PATH` - `PYTHONFINDER_IGNORE_UNSUPPORTED` Pipenv–specific environment variables: - `PIPENV_MAX_DEPTH`: `5` Debug–specific environment variables: --------------------------- Contents of `Pipfile` ('C:\\Users\\****\\Documents\\workspace\\tmp\\Pipfile'): ```toml [[source]] url = "https://pypi.org/simple" verify_ssl = true name = "pypi" [packages] [dev-packages] [requires] python_version = "3.8" ```
matteius commented 2 years ago

@souris4science Have you tried with pipenv==2022.1.8? I expect it might be the same because subprocesses are used in the install and locking process, so I am not sure it is viable to popup a UI prompting you for your username and PW

souris4science commented 2 years ago

@matteius I gave it a try today and the problem still occurs with pipenv==2022.1.8.