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

Installing environments fails: No matching distribution found for setuptools>=38.2.5 #960

Closed
mnboos opened this issue Mar 4, 2019 · 14 comments

Comments

@mnboos
Copy link

mnboos commented Mar 4, 2019

Each time I try to commit something, the following error appears:

Python version: 3.6.7

[INFO] Installing environment for https://github.com/ambv/black.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: Command: ('F:\\.cache\\pre-commit\\repo_d7sntw_\\py_env-python3.6\\Scripts\\pip.exe', 'install', '.')
Return code: 1
Expected return code: 0
Output:
    Processing f:\.cache\pre-commit\repo_d7sntw_
      Installing build dependencies: started
      Installing build dependencies: finished with status 'error'
      Complete output from command f:\.cache\pre-commit\repo_d7sntw_\py_env-python3.6\scripts\python.exe -m pip install --ignore-installed --no-user --prefix C:\Users\bmar\AppData\Local\Temp\pip-build-env-jlhy83f_ --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools>=38.2.5 wheel:
      Collecting setuptools>=38.2.5
        Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000173CCA64390>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed',)': /simple/setuptools/
        Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000173CCA64278>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed',)': /simple/setuptools/
        Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000173CCA645C0>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed',)': /simple/setuptools/
        Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000173CCA64208>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed',)': /simple/setuptools/
        Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000173CCA4E630>: Failed to establish a new connection: [Errno 11003] getaddrinfo failed',)': /simple/setuptools/
        Could not find a version that satisfies the requirement setuptools>=38.2.5 (from versions: )
      No matching distribution found for setuptools>=38.2.5

      ----------------------------------------

Errors:
    Command "f:\.cache\pre-commit\repo_d7sntw_\py_env-python3.6\scripts\python.exe -m pip install --ignore-installed --no-user --prefix C:\Users\bmar\AppData\Local\Temp\pip-build-env-jlhy83f_ --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools>=38.2.5 wheel" failed with error code 1 in None

.pre-commit-config.yaml

repos:
-   repo: https://github.com/ambv/black
    rev: 18.9b0
    hooks:
    - id: black
      language_version: python3.6
-   repo: https://gitlab.com/pycqa/flake8
    rev: 3.7.7  # pick a git hash / tag to point to
    hooks:
    -   id: flake8
        args: [--show-source, --statistics, --doctests]
@asottile
Copy link
Member

asottile commented Mar 4, 2019

That error looks like either your installation of python3.6 is broken, pypi was temporarily down, or your dns settings are broken -- none of which pre-commit can do anything about. Does it persist if you try again?

@asottile
Copy link
Member

asottile commented Mar 4, 2019

I found this which is potentially related: pypa/pip#5568

@mnboos
Copy link
Author

mnboos commented Mar 5, 2019

Does this mean, pre-commit installs the required packages within a virtual environment? Because it even fails, if I run it outside of a venv.

It worked at home, but failed on the machine of a work collegue. I fear it's somehow related to our network config (which we cannot change).

@mnboos
Copy link
Author

mnboos commented Mar 5, 2019

I now notice, the commands are run from the F:\ drive, even though my console is on C:\ as well as my userprofile and python installation.

And if I run pre-commit manually, it works like a charm:

Check the log at F:\/.cache\pre-commit\pre-commit.log

c:\src\prj>pre-commit
black....................................................................Failed
hookid: black

Files were modified by this hook. Additional output:

All done! \u2728 \U0001f370 \u2728
1 file reformatted.

flake8...................................................................Failed

But if this is triggered by git commit -am "test commit" things go south.

@asottile
Copy link
Member

asottile commented Mar 5, 2019

that is very weird! If you re-run pre-commit install does it fix committing?

The F:/ bits are coming from os.path.expanduser('~/...') which on windows I believe looks at the HOMEPATH variable

@asottile
Copy link
Member

asottile commented Mar 9, 2019

@mnboos any updates?

@mnboos
Copy link
Author

mnboos commented Mar 9, 2019

It's not working yet. Setting PYTHONPATH didn't help either. I don't want to blame pre-commit, because it seems to work for everbody else and it works on my Ubuntu VM.

@asottile
Copy link
Member

asottile commented Mar 9, 2019

It's interesting to me that pre-commit (when run by itself) works, but not inside git.

Can you run this for me?

python -c 'import pprint, os; pprint.pprint(tuple(sorted(os.environ.items())))'

And try putting this near the beginning of .git/hooks/pre-commit

import os, pprint
pprint.pprint(tuple(sorted(os.environ.items())))

And then running git commit and posting the output of those two commands here? I'd be curious to see if there's any environment differences.

Can you also run each of these commands and produce their output here? Might help in debugging what's different 🤔

which -a pre-commit
grep INSTALL_PYTHON .git/hooks/pre-commit
python -c 'import pre_commit; print(pre_commit.__file__)'
echo $HOMEPATH
echo $PRE_COMMIT_HOME
echo $XDG_CACHE_HOME
python3 -c 'import os.path; print(os.path.expanduser('~/.cache')

@mnboos
Copy link
Author

mnboos commented Mar 11, 2019

Just for clarification: I'm using a Windows machine here, not Linux (i.e. it works on Linux, not on this Windows machine)

c:\src>python -c "import pprint, os; pprint.pprint(tuple(sorted(os.environ.items())))"
(('ALLUSERSPROFILE', 'C:\\ProgramData'),
 ('APPDATA', 'C:\\Users\\bmar\\AppData\\Roaming'),
 ('BAZEL_SH', 'c:\\msys64\\usr\\bin\\bash.exe'),
 ('COMMONPROGRAMFILES', 'C:\\Program Files\\Common Files'),
 ('COMMONPROGRAMFILES(X86)', 'C:\\Program Files (x86)\\Common Files'),
 ('COMMONPROGRAMW6432', 'C:\\Program Files\\Common Files'),
 ('COMPOSE_CONVERT_WINDOWS_PATHS', 'true'),
 ('COMPUTERNAME', 'COMP'),
 ('COMSPEC', 'C:\\Windows\\system32\\cmd.exe'),
 ('DOCKER_CERT_PATH', 'C:\\Users\\bmar\\.docker\\machine\\machines\\default'),
 ('DOCKER_HOST', 'tcp://192.168.99.102:2376'),
 ('DOCKER_MACHINE_NAME', 'default'),
 ('DOCKER_TLS_VERIFY', '1'),
 ('DOCKER_TOOLBOX_INSTALL_PATH', 'C:\\Program Files\\Docker Toolbox'),
 ('DRIVERDATA', 'C:\\Windows\\System32\\Drivers\\DriverData'),
 ('FLEXLM_TIMEOUT', '2000000'),
 ('HOMEDRIVE', 'F:'),
 ('HOMEPATH', '\\'),
 ('HOMESHARE', '\\\\somenetworkpath.com\\abcd\\Users\\BMAR'),
 ('INTELOCLPATH',
  'C:\\Intel\\OpenCL\\sdk\\bin\\x64;C:\\Intel\\OpenCL\\sdk\\bin\\x86'),
 ('INTELOCLSDKROOT', 'C:\\Intel\\OpenCL\\sdk\\'),
 ('JAVA_HOME', 'C:\\Program Files\\Java\\jdk1.8.0_191'),
 ('LOCALAPPDATA', 'C:\\Users\\bmar\\AppData\\Local'),
 ('LOGONSERVER', '\\\\XY'),
 ('MINISHIFT_HOME', 'C:\\Users\\bmar\\.minishift'),
 ('NO_PROXY', '192.168.99.100,192.168.99.101,192.168.99.102'),
 ('NUMBER_OF_PROCESSORS', '8'),
 ('OS', 'Windows_NT'),
 ('PATH',
  'C:\\Program Files (x86)\\Microsoft '
  'SDKs\\Azure\\CLI2\\wbin;C:\\Intel\\OpenCL\\sdk\\bin\\x64;C:\\Intel\\OpenCL\\sdk\\bin\\x86;C:\\Intel\\OpenCL\\sdk\\bin\\Pin;C:\\Intel\\OpenCL\\sdk\\bin\\GTPin;C:\\Program '
  'Files (x86)\\Common '
  'Files\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program '
  'Files\\Intel\\WiFi\\bin\\;C:\\Program Files\\Common '
  'Files\\Intel\\WirelessCommon\\;C:\\Program Files\\Git\\cmd;C:\\Program '
  'Files\\dotnet\\;C:\\Program Files\\CMake\\bin;C:\\Program '
  'Files\\Perforce\\;C:\\Program Files\\Microsoft SQL '
  'Server\\130\\Tools\\Binn\\;C:\\Program Files (x86)\\Bitvise SSH '
  'Client;C:\\Users\\bmar\\AppData\\Local\\Continuum\\miniconda3;C:\\Users\\bmar\\AppData\\Local\\Continuum\\miniconda3\\Library\\mingw-w64\\bin;C:\\Users\\bmar\\AppData\\Local\\Continuum\\miniconda3\\Library\\usr\\bin;C:\\Users\\bmar\\AppData\\Local\\Continuum\\miniconda3\\Library\\bin;C:\\Users\\bmar\\AppData\\Local\\Continuum\\miniconda3\\Scripts;C:\\Users\\bmar\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\bmar\\AppData\\Local\\Programs\\Microsoft '
  'VS Code\\bin;C:\\Program Files\\Docker Toolbox;C:\\Program '
  'Files\\Oracle\\VirtualBox;C:\\msys64\\mingw64\\bin;C:\\msys64\\usr\\bin;C:\\Program '
  'Files\\Docker Toolbox;C:\\kubectl;C:\\bazel;C:\\Program '
  'Files\\LLVM\\bin;C:\\VulkanSDK\\1.1.97.0\\Bin;C:\\Program '
  'Files\\7-Zip;C:\\apache-maven-3.6.0\\bin'),
 ('PATHEXT', '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC'),
 ('PROCESSOR_ARCHITECTURE', 'AMD64'),
 ('PROCESSOR_IDENTIFIER',
  'Intel'),
 ('PROCESSOR_LEVEL', '6'),
 ('PROCESSOR_REVISION', ''),
 ('PROGRAMDATA', 'C:\\ProgramData'),
 ('PROGRAMFILES', 'C:\\Program Files'),
 ('PROGRAMFILES(X86)', 'C:\\Program Files (x86)'),
 ('PROGRAMW6432', 'C:\\Program Files'),
 ('PROMPT', '$P$G'),
 ('PSMODULEPATH',
  'C:\\Program '
  'Files\\WindowsPowerShell\\Modules;C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules'),
 ('PUBLIC', 'C:\\Users\\Public'),
 ('SESSIONNAME', 'Console'),
 ('SYSTEMDRIVE', 'C:'),
 ('SYSTEMROOT', 'C:\\Windows'),
 ('TEMP', 'C:\\Users\\bmar\\AppData\\Local\\Temp'),
 ('TMP', 'C:\\Users\\bmar\\AppData\\Local\\Temp'),
 ('USERDNSDOMAIN', '),
 ('USERDOMAIN', ''),
 ('USERDOMAIN_ROAMINGPROFILE', ''),
 ('USERNAME', 'bmar'),
 ('USERPROFILE', 'C:\\Users\\bmar'),
 ('VBOX_MSI_INSTALL_PATH', 'C:\\Program Files\\Oracle\\VirtualBox\\'),
 ('VS140COMNTOOLS',
  'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\'),
 ('WINDIR', 'C:\\Windows'))
c:\src>which -a pre-commit
/c/Users/bmar/AppData/Local/Continuum/miniconda3/Scripts/pre-commit
C:\src>grep INSTALL_PYTHON .git/hooks/pre-commit
INSTALL_PYTHON = 'c:\\users\\bmar\\appdata\\local\\continuum\\miniconda3\\python.exe'
        for exe in (INSTALL_PYTHON, sys.executable):
C:\src>python -c "import pre_commit; print(pre_commit.__file__)"
C:\Users\bmar\AppData\Local\Continuum\miniconda3\lib\site-packages\pre_commit\__init__.py
C:\src>echo %HOMEPATH%
\
c:\src>echo %pre_commit_home%
%pre_commit_home%                      <------- this means the variable is not set
c:\src>echo %XDG_CACHE_HOME%
%XDG_CACHE_HOME%                       <------- this means the variable is not set
c:\src>python3 -c "import os.path; print(os.path.expanduser('~/.cache'))"
C:\Users\bmar/.cache
C:\src\Simpala>git commit -am "test commit"
[INFO] Installing environment for https://github.com/ambv/black.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: Command: ('F:\\.cache\\pre-commit\\repoz9_8twq4\\py_env-python3\\Scripts\\pip.exe', 'install', '.')
Return code: 1
Expected return code: 0
Output:
    Processing f:\.cache\pre-commit\repoz9_8twq4
      Installing build dependencies: started
      Installing build dependencies: finished with status 'error'
      Complete output from command f:\.cache\pre-commit\repoz9_8twq4\py_env-python3\scripts\python.exe f:\.cache\pre-commit\repoz9_8twq4\py_env-python3\lib\site-packages\pip install --ignore-installed --no-user --prefix C:\Users\bmar\AppData\Local\Temp\pip-build-env-t
fpqq5_a\overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools>=40.8.0 wheel:
      Collecting setuptools>=40.8.0
        Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000250714A4668>: Failed to establish a new connection: [Errno 1
1003] getaddrinfo failed')': /simple/setuptools/
        Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000250714A4588>: Failed to establish a new connection: [Errno 1
1003] getaddrinfo failed')': /simple/setuptools/
        Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000002507148DAC8>: Failed to establish a new connection: [Errno 1
1003] getaddrinfo failed')': /simple/setuptools/
        Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000002507148D898>: Failed to establish a new connection: [Errno 1
1003] getaddrinfo failed')': /simple/setuptools/
        Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000002507148D1D0>: Failed to establish a new connection: [Errno 1
1003] getaddrinfo failed')': /simple/setuptools/
        Could not find a version that satisfies the requirement setuptools>=40.8.0 (from versions: )
      No matching distribution found for setuptools>=40.8.0

      ----------------------------------------

Errors:
    Command "f:\.cache\pre-commit\repoz9_8twq4\py_env-python3\scripts\python.exe f:\.cache\pre-commit\repoz9_8twq4\py_env-python3\lib\site-packages\pip install --ignore-installed --no-user --prefix C:\Users\bmar\AppData\Local\Temp\pip-build-env-tfpqq5_a\overlay --no-w
arn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools>=40.8.0 wheel" failed with error code 1 in None


Check the log at F:\/.cache\pre-commit\pre-commit.log
(('ALLUSERSPROFILE', 'C:\\ProgramData'),
 ('APPDATA', 'C:\\Users\\bmar\\AppData\\Roaming'),
 ('BAZEL_SH', 'c:\\msys64\\usr\\bin\\bash.exe'),
 ('CHARSET', 'cp1252'),
 ('COMMONPROGRAMFILES', 'C:\\Program Files\\Common Files'),
 ('COMMONPROGRAMFILES(X86)', 'C:\\Program Files (x86)\\Common Files'),
 ('COMMONPROGRAMW6432', 'C:\\Program Files\\Common Files'),
 ('COMPOSE_CONVERT_WINDOWS_PATHS', 'true'),
 ('COMPUTERNAME', 'computer'),
 ('COMSPEC', 'C:\\Windows\\system32\\cmd.exe'),
 ('DOCKER_CERT_PATH', 'C:\\Users\\bmar\\.docker\\machine\\machines\\default'),
 ('DOCKER_HOST', 'tcp://192.168.99.102:2376'),
 ('DOCKER_MACHINE_NAME', 'default'),
 ('DOCKER_TLS_VERIFY', '1'),
 ('DOCKER_TOOLBOX_INSTALL_PATH', 'C:\\Program Files\\Docker Toolbox'),
 ('DRIVERDATA', 'C:\\Windows\\System32\\Drivers\\DriverData'),
 ('FLEXLM_TIMEOUT', '2000000'),
 ('GIT_AUTHOR_DATE', '@1552284845 +0100'),
 ('GIT_AUTHOR_EMAIL', ''),
 ('GIT_AUTHOR_NAME', ''),
 ('GIT_EDITOR', ':'),
 ('GIT_EXEC_PATH', 'C:/Program Files/Git/mingw64/libexec/git-core'),
 ('GIT_INDEX_FILE', 'C:/src/theproject/.git/index.lock'),
 ('GIT_PREFIX', ''),
 ('HOME', 'F:\\'),
 ('HOMEDRIVE', 'F:'),
 ('HOMEPATH', '\\'),
 ('HOMESHARE', '\\\\asdf\\sdfg\\Users\\xyz\\BMAR'),
 ('INTELOCLPATH',
  'C:\\Intel\\OpenCL\\sdk\\bin\\x64;C:\\Intel\\OpenCL\\sdk\\bin\\x86'),
 ('INTELOCLSDKROOT', 'C:\\Intel\\OpenCL\\sdk\\'),
 ('JAVA_HOME', 'C:\\Program Files\\Java\\jdk1.8.0_191'),
 ('LC_CTYPE', 'C'),
 ('LOCALAPPDATA', 'C:\\Users\\bmar\\AppData\\Local'),
 ('LOGONSERVER', '\\\\fdadsfd'),
 ('MINISHIFT_HOME', 'C:\\Users\\bmar\\.minishift'),
 ('MSYSTEM', 'MINGW64'),
 ('NO_PROXY', '192.168.99.100,192.168.99.101,192.168.99.102'),
 ('NUMBER_OF_PROCESSORS', '8'),
 ('OS', 'Windows_NT'),
 ('PATH',
  'C:\\Program Files\\Git\\mingw64\\libexec\\git-core;C:\\Program '
  'Files\\Git\\mingw64\\bin;C:\\Program '
  'Files\\Git\\usr\\bin;F:\\bin;C:\\Program Files (x86)\\Microsoft '
  'SDKs\\Azure\\CLI2\\wbin;C:\\Intel\\OpenCL\\sdk\\bin\\x64;C:\\Intel\\OpenCL\\sdk\\bin\\x86;C:\\Intel\\OpenCL\\sdk\\bin\\Pin;C:\\Intel\\OpenCL\\sdk\\bin\\GTPin;C:\\Program '
  'Files (x86)\\Common '
  'Files\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0;C:\\Windows\\System32\\OpenSSH;C:\\Program '
  'Files\\Intel\\WiFi\\bin;C:\\Program Files\\Common '
  'Files\\Intel\\WirelessCommon;C:\\Program Files\\Git\\cmd;C:\\Program '
  'Files\\dotnet;C:\\Program Files\\CMake\\bin;C:\\Program '
  'Files\\Perforce;C:\\Program Files\\Microsoft SQL '
  'Server\\130\\Tools\\Binn;C:\\Program Files (x86)\\Bitvise SSH '
  'Client;C:\\Users\\bmar\\AppData\\Local\\Continuum\\miniconda3;C:\\Users\\bmar\\AppData\\Local\\Continuum\\miniconda3\\Library\\mingw-w64\\bin;C:\\Users\\bmar\\AppData\\Local\\Continuum\\miniconda3\\Library\\usr\\bin;C:\\Users\\bmar\\AppData\\Local\\Continuum\\minic
onda3\\Library\\bin;C:\\Users\\bmar\\AppData\\Local\\Continuum\\miniconda3\\Scripts;C:\\Users\\bmar\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\bmar\\AppData\\Local\\Programs\\Microsoft '
  'VS Code\\bin;C:\\Program Files\\Docker Toolbox;C:\\Program '
  'Files\\Oracle\\VirtualBox;C:\\msys64\\mingw64\\bin;C:\\msys64\\usr\\bin;C:\\Program '
  'Files\\Docker Toolbox;C:\\kubectl;C:\\bazel;C:\\Program '
  'Files\\LLVM\\bin;C:\\VulkanSDK\\1.1.97.0\\Bin;C:\\Program '
  'Files\\7-Zip;C:\\apache-maven-3.6.0\\bin'),
 ('PATHEXT', '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC'),
 ('PLINK_PROTOCOL', 'ssh'),
 ('PROCESSOR_ARCHITECTURE', 'AMD64'),
 ('PROCESSOR_IDENTIFIER',
  'Intel64'),
 ('PROCESSOR_LEVEL', '6'),
 ('PROCESSOR_REVISION', '8e0a'),
 ('PROGRAMDATA', 'C:\\ProgramData'),
 ('PROGRAMFILES', 'C:\\Program Files'),
 ('PROGRAMFILES(X86)', 'C:\\Program Files (x86)'),
 ('PROGRAMW6432', 'C:\\Program Files'),
 ('PROMPT', '$P$G'),
 ('PSMODULEPATH',
  'C:\\Program '
  'Files\\WindowsPowerShell\\Modules;C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules'),
 ('PUBLIC', 'C:\\Users\\Public'),
 ('SYSTEMDRIVE', 'C:'),
 ('SYSTEMROOT', 'C:\\Windows'),
 ('TEMP', 'C:\\Users\\bmar\\AppData\\Local\\Temp'),
 ('TERM', 'cygwin'),
 ('TERMINAL_EMULATOR', 'JetBrains-JediTerm'),
 ('TMP', 'C:\\Users\\bmar\\AppData\\Local\\Temp'),
 ('TMPDIR', 'C:\\Users\\bmar\\AppData\\Local\\Temp'),
 ('USERDNSDOMAIN', something.COM'),
 ('USERDOMAIN', ''),
 ('USERDOMAIN_ROAMINGPROFILE', ''),
 ('USERNAME', 'bmar'),
 ('USERPROFILE', 'C:\\Users\\bmar'),
 ('VBOX_MSI_INSTALL_PATH', 'C:\\Program Files\\Oracle\\VirtualBox\\'),
 ('VS140COMNTOOLS',
  'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\'),
 ('WINDIR', 'C:\\Windows'),
 ('__INTELLIJ_COMMAND_HISTFILE__',
  'C:\\Users\\bmar\\.PyCharmCE2018.3\\config\\terminal\\history\\history-1'))

@mnboos
Copy link
Author

mnboos commented Mar 11, 2019

I found a workaround (i.e. set HOMEDRIVE=C:)

C:\src\Simpala>set HOMEDRIVE=C:

C:\src\Simpala>echo %HOMEDRIVE%
C:

C:\src\Simpala>git commit -am "test commit"
[INFO] Initializing environment for https://github.com/ambv/black.
[INFO] Initializing environment for https://gitlab.com/pycqa/flake8.
[INFO] Installing environment for https://github.com/ambv/black.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://gitlab.com/pycqa/flake8.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
black....................................................................Failed
hookid: black

Files were modified by this hook. Additional output:

reformatted C:\src\runl.py

...

@asottile
Copy link
Member

asottile commented Mar 11, 2019

Interesting, that does appear to be the difference.

Here's the relevant diff from the environ splat that I can see:

--- outside	2019-03-11 08:38:34.857174146 -0700
+++ inside	2019-03-11 08:38:46.916672996 -0700
 
 ...
+ ('HOME', 'F:\\'),

What I believe is happening:

  • git commands go through git.exe which is an msys program. This "normalizes" the environment for POSIX, among other things making sure HOME is set. I suspect there's a microbug in msys which makes HOMEDRIVE=F: and HOME=\\ normalize to HOME=F:\\ (this is probably a bug in msys, it should honor USERPROFILE first).
  • os.path.expanduser on windows uses os.environ['HOME'] in preference to os.environ['USERPROFILE'] -- this is ~maybe a bug in python
  • (this causes pre-commit to build environments on that network drive, tickling the pip bug above)

In your case, I'd suggest the following workaround instead, to set HOME=%USERPROFILE%

Is that something you can configure for your user?

@asottile
Copy link
Member

I've created a bpo issue for this: https://bugs.python.org/issue36264

@asottile
Copy link
Member

yay, python3.8 will ship with a fix to os.path.expanduser -- and you have a workaround for now by setting an environment variable

I couldn't figure out how to send an issue to mingw for the HOME thing :S

I think there's nothing left to do here so I'm closing this -- thanks for the issue 🎉

@mnboos
Copy link
Author

mnboos commented Mar 14, 2019

Awesome! Thanks a lot for your support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants