Repository: pre-commit/pre-commit

Issue:
pre-commit install yields FileExistsError: [Errno 17] File exists: '/Users/vsts/.cache/pre-commit'
**Problem**: pre-commit install sometimes (not always) returns: FileExistsError: [Errno 17] File exists: \'/Users/vsts/.cache/pre-commit\'

**OS**: Occurs on Ubuntu and Mac, not tested for Windows.

**Setup**: For our cookiecutter project (https://github.com/hmgaudecker/econ-project-templates), we use pytests to test if the projected created fails our pre-commit hooks. We run the pytests on azure. The project is tested for multiple project configurations. 

The tests are setup in the following way:
```python 
def _check_pre_commit(result):
    subprocess.Popen(
        "pre-commit install",
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        shell=True,
        cwd=result.project,
    )
    c = subprocess.Popen(
        "pre-commit run --all-files",
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        shell=True,
        cwd=result.project,
    )
    output, error = c.communicate()

    failure = re.search(r"Failed", str(output))
    if failure is not None:
        print(output)
        raise AssertionError("Some pre-commit failed.")
    # Not trivial to check for empty string if it might be binary stream
    assert len(error) == 0, "{}".format(str(error))
    assert re.search(
        r"(Passed|Failed)", str(output)
    ), "All files skipped by pre-commit."
```
were result.project is a temporary directory created.

**Expected Output**: Should fail if a pre-commit fails, and pass otherwise.

**Output**: The first of the pre-commit tests fails on a non-systematic basis, sometimes only on Linux, sometimes only on Mac OS, with the ouput:

```An unexpected error has occurred: FileExistsError: [Errno 17] File exists: \'/Users/vsts/.cache/pre-commit\'\\nCheck the log at /Users/vsts/.cache/pre-commit/pre-commit.log\\n```

The subsequent tests pass on each operating system.

UPDATE: full log contents:
```
019-10-21T13:00:08.5581220Z ##[section]Starting: Run pytests.
2019-10-21T13:00:08.5588010Z ==============================================================================
2019-10-21T13:00:08.5588250Z Task         : Bash
2019-10-21T13:00:08.5588370Z Description  : Run a Bash script on macOS, Linux, or Windows
2019-10-21T13:00:08.5588560Z Version      : 3.151.3
2019-10-21T13:00:08.5588680Z Author       : Microsoft Corporation
2019-10-21T13:00:08.5588880Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/bash
2019-10-21T13:00:08.5589020Z ==============================================================================
2019-10-21T13:00:08.7618090Z Generating script.
2019-10-21T13:00:08.7670820Z ========================== Starting Command Output ===========================
2019-10-21T13:00:08.7702280Z [command]/bin/bash --noprofile --norc /Users/vsts/agent/2.158.0/work/_temp/066caadb-d509-4ebf-b933-863eae05fa12.sh
2019-10-21T13:00:23.3554080Z ============================= test session starts ==============================
2019-10-21T13:00:23.3561040Z platform darwin -- Python 3.7.4, pytest-5.2.1, py-1.8.0, pluggy-0.13.0
2019-10-21T13:00:23.3655960Z rootdir: /Users/vsts/agent/2.158.0/work/1/s
2019-10-21T13:00:23.3657390Z plugins: cookies-0.4.0, pythonpath-0.7.3, cov-2.8.1
2019-10-21T13:00:24.0809650Z collected 27 items
2019-10-21T13:00:24.0849280Z 
2019-10-21T13:01:45.0038630Z tests/test_cookie.py ........                                            [ 29%]
2019-10-21T13:03:21.6364550Z tests/test_pre_commit.py F.....                                          [ 51%]
2019-10-21T13:06:45.6358110Z tests/test_waf.py .......xxxxxx                                          [100%]
2019-10-21T13:06:45.6372100Z 
2019-10-21T13:06:45.6372800Z =================================== FAILURES ===================================
2019-10-21T13:06:45.6373690Z ________________________ test_pre_commit_python_sphinx _________________________
2019-10-21T13:06:45.6374290Z 
2019-10-21T13:06:45.6374770Z cookies = <pytest_cookies.plugin.Cookies object at 0x108e5d790>
2019-10-21T13:06:45.6378350Z basic_project_dict = {'_copy_without_render': ['.mywaflib', '*.bib', 'src_matlab/library/matlab-json/*', 'src_stata/library/stata/ado_ext/*'], 'add_basic_pre_commit_hooks': 'y', 'add_intrusive_pre_commit': 'y', 'affiliation': 'Universität Hintertupfingen', ...}
2019-10-21T13:06:45.6378610Z 
2019-10-21T13:06:45.6378960Z     def test_pre_commit_python_sphinx(cookies, basic_project_dict):
2019-10-21T13:06:45.6379110Z         basic_project_dict["set_up_git"] = "y"
2019-10-21T13:06:45.6379360Z         basic_project_dict["make_initial_commit"] = "y"
2019-10-21T13:06:45.6379510Z         basic_project_dict["add_basic_pre_commit_hooks"] = "y"
2019-10-21T13:06:45.6382000Z         basic_project_dict["add_intrusive_pre_commit"] = "y"
2019-10-21T13:06:45.6382330Z         basic_project_dict["configure_running_sphinx_from_waf"] = "y"
2019-10-21T13:06:45.6397850Z         result = cookies.bake(extra_context=basic_project_dict)
2019-10-21T13:06:45.6398120Z >       _check_pre_commit(result)
2019-10-21T13:06:45.6398250Z 
2019-10-21T13:06:45.6398370Z tests/test_pre_commit.py:42: 
2019-10-21T13:06:45.6398600Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2019-10-21T13:06:45.6398710Z 
2019-10-21T13:06:45.6399950Z result = <Result /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pytest-of-vsts/pytest-0/test_pre_commit_python_sphinx0/cookies/bake00/research_project>
2019-10-21T13:06:45.6400110Z 
2019-10-21T13:06:45.6400300Z     def _check_pre_commit(result):
2019-10-21T13:06:45.6400430Z         subprocess.Popen(
2019-10-21T13:06:45.6401160Z             "pre-commit install",
2019-10-21T13:06:45.6401310Z             stdout=subprocess.PIPE,
2019-10-21T13:06:45.6401430Z             stderr=subprocess.PIPE,
2019-10-21T13:06:45.6401630Z             shell=True,
2019-10-21T13:06:45.6401750Z             cwd=result.project,
2019-10-21T13:06:45.6401980Z         )
2019-10-21T13:06:45.6402090Z         c = subprocess.Popen(
2019-10-21T13:06:45.6402890Z             "pre-commit run --all-files",
2019-10-21T13:06:45.6417140Z             stdout=subprocess.PIPE,
2019-10-21T13:06:45.6417290Z             stderr=subprocess.PIPE,
2019-10-21T13:06:45.6417350Z             shell=True,
2019-10-21T13:06:45.6417540Z             cwd=result.project,
2019-10-21T13:06:45.6417600Z         )
2019-10-21T13:06:45.6417770Z         output, error = c.communicate()
2019-10-21T13:06:45.6417840Z     
2019-10-21T13:06:45.6417980Z         failure = re.search(r"Failed", str(output))
2019-10-21T13:06:45.6418060Z         if failure is not None:
2019-10-21T13:06:45.6418160Z             print(output)
2019-10-21T13:06:45.6418770Z             raise AssertionError("Some pre-commit failed.")
2019-10-21T13:06:45.6418920Z         # Not trivial to check for empty string if it might be binary stream
2019-10-21T13:06:45.6419000Z         assert len(error) == 0, "{}".format(str(error))
2019-10-21T13:06:45.6419130Z >       assert re.search(
2019-10-21T13:06:45.6419190Z             r"(Passed|Failed)", str(output)
2019-10-21T13:06:45.6419630Z         ), "All files skipped by pre-commit."
2019-10-21T13:06:45.6420040Z E       AssertionError: All files skipped by pre-commit.
2019-10-21T13:06:45.6420330Z E       assert None
2019-10-21T13:06:45.6421080Z E        +  where None = <function search at 0x10714eb00>('(Passed|Failed)', 'b"An unexpected error has occurred: FileExistsError: [Errno 17] File exists: \'/Users/vsts/.cache/pre-commit\'\\nCheck the log at /Users/vsts/.cache/pre-commit/pre-commit.log\\n"')
2019-10-21T13:06:45.6421370Z E        +    where <function search at 0x10714eb00> = re.search
2019-10-21T13:06:45.6422110Z E        +    and   'b"An unexpected error has occurred: FileExistsError: [Errno 17] File exists: \'/Users/vsts/.cache/pre-commit\'\\nCheck the log at /Users/vsts/.cache/pre-commit/pre-commit.log\\n"' = str(b"An unexpected error has occurred: FileExistsError: [Errno 17] File exists: '/Users/vsts/.cache/pre-commit'\nCheck the log at /Users/vsts/.cache/pre-commit/pre-commit.log\n")
2019-10-21T13:06:45.6422330Z 
2019-10-21T13:06:45.6432870Z tests/test_pre_commit.py:30: AssertionError
2019-10-21T13:06:45.6434240Z ----------------------------- Captured stdout call -----------------------------
2019-10-21T13:06:45.6435300Z Initialized empty Git repository in /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pytest-of-vsts/pytest-0/test_pre_commit_python_sphinx0/cookies/bake00/research_project/.git/
2019-10-21T13:06:45.6436360Z [master (root-commit) 9f60b50] 'Initial commit with template from https://github.com/hmgaudecker/econ-project-templates'
2019-10-21T13:06:45.6436670Z  224 files changed, 43497 insertions(+)
2019-10-21T13:06:45.6436820Z  create mode 100755 .gitignore
2019-10-21T13:06:45.6437020Z  create mode 100755 .mywaflib/waflib/Build.py
2019-10-21T13:06:45.6437160Z  create mode 100755 .mywaflib/waflib/ConfigSet.py
2019-10-21T13:06:45.6437290Z  create mode 100755 .mywaflib/waflib/Configure.py
2019-10-21T13:06:45.6438000Z  create mode 100755 .mywaflib/waflib/Context.py
2019-10-21T13:06:45.6438130Z  create mode 100755 .mywaflib/waflib/Errors.py
2019-10-21T13:06:45.6438360Z  create mode 100755 .mywaflib/waflib/Logs.py
2019-10-21T13:06:45.6438500Z  create mode 100755 .mywaflib/waflib/Node.py
2019-10-21T13:06:45.6438690Z  create mode 100755 .mywaflib/waflib/Options.py
2019-10-21T13:06:45.6439020Z  create mode 100755 .mywaflib/waflib/Runner.py
2019-10-21T13:06:45.6439280Z  create mode 100755 .mywaflib/waflib/Scripting.py
2019-10-21T13:06:45.6439400Z  create mode 100755 .mywaflib/waflib/Task.py
2019-10-21T13:06:45.6439590Z  create mode 100755 .mywaflib/waflib/TaskGen.py
2019-10-21T13:06:45.6439720Z  create mode 100755 .mywaflib/waflib/Tools/__init__.py
2019-10-21T13:06:45.6439910Z  create mode 100755 .mywaflib/waflib/Tools/ar.py
2019-10-21T13:06:45.6440030Z  create mode 100755 .mywaflib/waflib/Tools/asm.py
2019-10-21T13:06:45.6440230Z  create mode 100755 .mywaflib/waflib/Tools/bison.py
2019-10-21T13:06:45.6440370Z  create mode 100755 .mywaflib/waflib/Tools/c.py
2019-10-21T13:06:45.6440570Z  create mode 100755 .mywaflib/waflib/Tools/c_aliases.py
2019-10-21T13:06:45.6441220Z  create mode 100755 .mywaflib/waflib/Tools/c_config.py
2019-10-21T13:06:45.6441440Z  create mode 100755 .mywaflib/waflib/Tools/c_osx.py
2019-10-21T13:06:45.6441570Z  create mode 100755 .mywaflib/waflib/Tools/c_preproc.py
2019-10-21T13:06:45.6441770Z  create mode 100755 .mywaflib/waflib/Tools/c_tests.py
2019-10-21T13:06:45.6441900Z  create mode 100755 .mywaflib/waflib/Tools/ccroot.py
2019-10-21T13:06:45.6442080Z  create mode 100755 .mywaflib/waflib/Tools/clang.py
2019-10-21T13:06:45.6442220Z  create mode 100755 .mywaflib/waflib/Tools/clangxx.py
2019-10-21T13:06:45.6442440Z  create mode 100755 .mywaflib/waflib/Tools/compiler_c.py
2019-10-21T13:06:45.6442570Z  create mode 100755 .mywaflib/waflib/Tools/compiler_cxx.py
2019-10-21T13:06:45.6442820Z  create mode 100755 .mywaflib/waflib/Tools/compiler_d.py
2019-10-21T13:06:45.6442960Z  create mode 100755 .mywaflib/waflib/Tools/compiler_fc.py
2019-10-21T13:06:45.6443180Z  create mode 100755 .mywaflib/waflib/Tools/cs.py
2019-10-21T13:06:45.6443330Z  create mode 100755 .mywaflib/waflib/Tools/cxx.py
2019-10-21T13:06:45.6443530Z  create mode 100755 .mywaflib/waflib/Tools/d.py
2019-10-21T13:06:45.6443660Z  create mode 100755 .mywaflib/waflib/Tools/d_config.py
2019-10-21T13:06:45.6443850Z  create mode 100755 .mywaflib/waflib/Tools/d_scan.py
2019-10-21T13:06:45.6444000Z  create mode 100755 .mywaflib/waflib/Tools/dbus.py
2019-10-21T13:06:45.6444200Z  create mode 100755 .mywaflib/waflib/Tools/dmd.py
2019-10-21T13:06:45.6444340Z  create mode 100755 .mywaflib/waflib/Tools/errcheck.py
2019-10-21T13:06:45.6444540Z  create mode 100755 .mywaflib/waflib/Tools/fc.py
2019-10-21T13:06:45.6444680Z  create mode 100755 .mywaflib/waflib/Tools/fc_config.py
2019-10-21T13:06:45.6444870Z  create mode 100755 .mywaflib/waflib/Tools/fc_scan.py
2019-10-21T13:06:45.6445010Z  create mode 100755 .mywaflib/waflib/Tools/flex.py
2019-10-21T13:06:45.6445210Z  create mode 100755 .mywaflib/waflib/Tools/g95.py
2019-10-21T13:06:45.6445360Z  create mode 100755 .mywaflib/waflib/Tools/gas.py
2019-10-21T13:06:45.6445860Z  create mode 100755 .mywaflib/waflib/Tools/gcc.py
2019-10-21T13:06:45.6446020Z  create mode 100755 .mywaflib/waflib/Tools/gdc.py
2019-10-21T13:06:45.6446200Z  create mode 100755 .mywaflib/waflib/Tools/gfortran.py
2019-10-21T13:06:45.6446330Z  create mode 100755 .mywaflib/waflib/Tools/glib2.py
2019-10-21T13:06:45.6446450Z  create mode 100755 .mywaflib/waflib/Tools/gnu_dirs.py
2019-10-21T13:06:45.6494530Z  create mode 100755 .mywaflib/waflib/Tools/gxx.py
2019-10-21T13:06:45.6495120Z  create mode 100755 .mywaflib/waflib/Tools/icc.py
2019-10-21T13:06:45.6495340Z  create mode 100755 .mywaflib/waflib/Tools/icpc.py
2019-10-21T13:06:45.6495490Z  create mode 100755 .mywaflib/waflib/Tools/ifort.py
2019-10-21T13:06:45.6495680Z  create mode 100755 .mywaflib/waflib/Tools/intltool.py
2019-10-21T13:06:45.6495820Z  create mode 100755 .mywaflib/waflib/Tools/irixcc.py
2019-10-21T13:06:45.6496940Z  create mode 100755 .mywaflib/waflib/Tools/javaw.py
2019-10-21T13:06:45.6497260Z  create mode 100755 .mywaflib/waflib/Tools/ldc2.py
2019-10-21T13:06:45.6497590Z  create mode 100755 .mywaflib/waflib/Tools/lua.py
2019-10-21T13:06:45.6497890Z  create mode 100755 .mywaflib/waflib/Tools/md5_tstamp.py
2019-10-21T13:06:45.6498030Z  create mode 100755 .mywaflib/waflib/Tools/msvc.py
2019-10-21T13:06:45.6498250Z  create mode 100755 .mywaflib/waflib/Tools/nasm.py
2019-10-21T13:06:45.6498480Z  create mode 100755 .mywaflib/waflib/Tools/nobuild.py
2019-10-21T13:06:45.6498610Z  create mode 100755 .mywaflib/waflib/Tools/perl.py
2019-10-21T13:06:45.6498680Z  create mode 100755 .mywaflib/waflib/Tools/python.py
2019-10-21T13:06:45.6498870Z  create mode 100755 .mywaflib/waflib/Tools/qt5.py
2019-10-21T13:06:45.6498940Z  create mode 100755 .mywaflib/waflib/Tools/ruby.py
2019-10-21T13:06:45.6499030Z  create mode 100755 .mywaflib/waflib/Tools/suncc.py
2019-10-21T13:06:45.6499110Z  create mode 100755 .mywaflib/waflib/Tools/suncxx.py
2019-10-21T13:06:45.6499210Z  create mode 100755 .mywaflib/waflib/Tools/tex.py
2019-10-21T13:06:45.6501910Z  create mode 100755 .mywaflib/waflib/Tools/vala.py
2019-10-21T13:06:45.6502020Z  create mode 100755 .mywaflib/waflib/Tools/waf_unit_test.py
2019-10-21T13:06:45.6502100Z  create mode 100755 .mywaflib/waflib/Tools/winres.py
2019-10-21T13:06:45.6502190Z  create mode 100755 .mywaflib/waflib/Tools/xlc.py
2019-10-21T13:06:45.6502250Z  create mode 100755 .mywaflib/waflib/Tools/xlcxx.py
2019-10-21T13:06:45.6502350Z  create mode 100755 .mywaflib/waflib/Utils.py
2019-10-21T13:06:45.6502410Z  create mode 100755 .mywaflib/waflib/__init__.py
2019-10-21T13:06:45.6502500Z  create mode 100755 .mywaflib/waflib/ansiterm.py
2019-10-21T13:06:45.6502570Z  create mode 100755 .mywaflib/waflib/extras/__init__.py
2019-10-21T13:06:45.6502670Z  create mode 100755 .mywaflib/waflib/extras/batched_cc.py
2019-10-21T13:06:45.6502740Z  create mode 100755 .mywaflib/waflib/extras/biber.py
2019-10-21T13:06:45.6502850Z  create mode 100755 .mywaflib/waflib/extras/bjam.py
2019-10-21T13:06:45.6502920Z  create mode 100755 .mywaflib/waflib/extras/blender.py
2019-10-21T13:06:45.6503020Z  create mode 100755 .mywaflib/waflib/extras/boo.py
2019-10-21T13:06:45.6503090Z  create mode 100755 .mywaflib/waflib/extras/boost.py
2019-10-21T13:06:45.6503190Z  create mode 100755 .mywaflib/waflib/extras/build_file_tracker.py
2019-10-21T13:06:45.6503260Z  create mode 100755 .mywaflib/waflib/extras/build_logs.py
2019-10-21T13:06:45.6503370Z  create mode 100755 .mywaflib/waflib/extras/buildcopy.py
2019-10-21T13:06:45.6503440Z  create mode 100755 .mywaflib/waflib/extras/c_bgxlc.py
2019-10-21T13:06:45.6503540Z  create mode 100755 .mywaflib/waflib/extras/c_dumbpreproc.py
2019-10-21T13:06:45.6503620Z  create mode 100755 .mywaflib/waflib/extras/c_emscripten.py
2019-10-21T13:06:45.6503720Z  create mode 100755 .mywaflib/waflib/extras/c_nec.py
2019-10-21T13:06:45.6503790Z  create mode 100755 .mywaflib/waflib/extras/cabal.py
2019-10-21T13:06:45.6503900Z  create mode 100755 .mywaflib/waflib/extras/cfg_altoptions.py
2019-10-21T13:06:45.6503980Z  create mode 100755 .mywaflib/waflib/extras/clang_compilation_database.py
2019-10-21T13:06:45.6504090Z  create mode 100755 .mywaflib/waflib/extras/codelite.py
2019-10-21T13:06:45.6504160Z  create mode 100755 .mywaflib/waflib/extras/color_gcc.py
2019-10-21T13:06:45.6504350Z  create mode 100755 .mywaflib/waflib/extras/color_rvct.py
2019-10-21T13:06:45.6504440Z  create mode 100755 .mywaflib/waflib/extras/compat15.py
2019-10-21T13:06:45.6504540Z  create mode 100755 .mywaflib/waflib/extras/cppcheck.py
2019-10-21T13:06:45.6504610Z  create mode 100755 .mywaflib/waflib/extras/cpplint.py
2019-10-21T13:06:45.6504710Z  create mode 100755 .mywaflib/waflib/extras/cross_gnu.py
2019-10-21T13:06:45.6504780Z  create mode 100755 .mywaflib/waflib/extras/cython.py
2019-10-21T13:06:45.6504890Z  create mode 100755 .mywaflib/waflib/extras/dcc.py
2019-10-21T13:06:45.6504960Z  create mode 100755 .mywaflib/waflib/extras/distnet.py
2019-10-21T13:06:45.6505310Z  create mode 100755 .mywaflib/waflib/extras/doxygen.py
2019-10-21T13:06:45.6505390Z  create mode 100755 .mywaflib/waflib/extras/dpapi.py
2019-10-21T13:06:45.6505500Z  create mode 100755 .mywaflib/waflib/extras/eclipse.py
2019-10-21T13:06:45.6505570Z  create mode 100755 .mywaflib/waflib/extras/erlang.py
2019-10-21T13:06:45.6505680Z  create mode 100755 .mywaflib/waflib/extras/fast_partial.py
2019-10-21T13:06:45.6505750Z  create mode 100755 .mywaflib/waflib/extras/fc_bgxlf.py
2019-10-21T13:06:45.6505850Z  create mode 100755 .mywaflib/waflib/extras/fc_cray.py
2019-10-21T13:06:45.6505920Z  create mode 100755 .mywaflib/waflib/extras/fc_nag.py
2019-10-21T13:06:45.6506030Z  create mode 100755 .mywaflib/waflib/extras/fc_nec.py
2019-10-21T13:06:45.6506110Z  create mode 100755 .mywaflib/waflib/extras/fc_open64.py
2019-10-21T13:06:45.6506170Z  create mode 100755 .mywaflib/waflib/extras/fc_pgfortran.py
2019-10-21T13:06:45.6506280Z  create mode 100755 .mywaflib/waflib/extras/fc_solstudio.py
2019-10-21T13:06:45.6507330Z  create mode 100755 .mywaflib/waflib/extras/fc_xlf.py
2019-10-21T13:06:45.6508390Z  create mode 100755 .mywaflib/waflib/extras/file_to_object.py
2019-10-21T13:06:45.6508480Z  create mode 100755 .mywaflib/waflib/extras/fluid.py
2019-10-21T13:06:45.6508620Z  create mode 100755 .mywaflib/waflib/extras/freeimage.py
2019-10-21T13:06:45.6508690Z  create mode 100755 .mywaflib/waflib/extras/fsb.py
2019-10-21T13:06:45.6508800Z  create mode 100755 .mywaflib/waflib/extras/fsc.py
2019-10-21T13:06:45.6508870Z  create mode 100755 .mywaflib/waflib/extras/gccdeps.py
2019-10-21T13:06:45.6508970Z  create mode 100755 .mywaflib/waflib/extras/gdbus.py
2019-10-21T13:06:45.6509040Z  create mode 100755 .mywaflib/waflib/extras/gob2.py
2019-10-21T13:06:45.6509140Z  create mode 100755 .mywaflib/waflib/extras/halide.py
2019-10-21T13:06:45.6509210Z  create mode 100755 .mywaflib/waflib/extras/javatest.py
2019-10-21T13:06:45.6509310Z  create mode 100755 .mywaflib/waflib/extras/kde4.py
2019-10-21T13:06:45.6509400Z  create mode 100755 .mywaflib/waflib/extras/local_rpath.py
2019-10-21T13:06:45.6509510Z  create mode 100755 .mywaflib/waflib/extras/make.py
2019-10-21T13:06:45.6509590Z  create mode 100755 .mywaflib/waflib/extras/midl.py
2019-10-21T13:06:45.6509690Z  create mode 100755 .mywaflib/waflib/extras/msvcdeps.py
2019-10-21T13:06:45.6509760Z  create mode 100755 .mywaflib/waflib/extras/msvs.py
2019-10-21T13:06:45.6509870Z  create mode 100755 .mywaflib/waflib/extras/netcache_client.py
2019-10-21T13:06:45.6509940Z  create mode 100755 .mywaflib/waflib/extras/objcopy.py
2019-10-21T13:06:45.6510040Z  create mode 100755 .mywaflib/waflib/extras/ocaml.py
2019-10-21T13:06:45.6510110Z  create mode 100755 .mywaflib/waflib/extras/package.py
2019-10-21T13:06:45.6510220Z  create mode 100755 .mywaflib/waflib/extras/parallel_debug.py
2019-10-21T13:06:45.6510290Z  create mode 100755 .mywaflib/waflib/extras/pch.py
2019-10-21T13:06:45.6510390Z  create mode 100755 .mywaflib/waflib/extras/pep8.py
2019-10-21T13:06:45.6510460Z  create mode 100755 .mywaflib/waflib/extras/pgicc.py
2019-10-21T13:06:45.6510570Z  create mode 100755 .mywaflib/waflib/extras/pgicxx.py
2019-10-21T13:06:45.6510640Z  create mode 100755 .mywaflib/waflib/extras/proc.py
2019-10-21T13:06:45.6510750Z  create mode 100755 .mywaflib/waflib/extras/protoc.py
2019-10-21T13:06:45.6510980Z  create mode 100755 .mywaflib/waflib/extras/pyqt5.py
2019-10-21T13:06:45.6511060Z  create mode 100755 .mywaflib/waflib/extras/pytest.py
2019-10-21T13:06:45.6511150Z  create mode 100755 .mywaflib/waflib/extras/qnxnto.py
2019-10-21T13:06:45.6511230Z  create mode 100755 .mywaflib/waflib/extras/qt4.py
2019-10-21T13:06:45.6511290Z  create mode 100755 .mywaflib/waflib/extras/relocation.py
2019-10-21T13:06:45.6511400Z  create mode 100755 .mywaflib/waflib/extras/remote.py
2019-10-21T13:06:45.6511470Z  create mode 100755 .mywaflib/waflib/extras/resx.py
2019-10-21T13:06:45.6511570Z  create mode 100755 .mywaflib/waflib/extras/review.py
2019-10-21T13:06:45.6511640Z  create mode 100755 .mywaflib/waflib/extras/rst.py
2019-10-21T13:06:45.6511990Z  create mode 100755 .mywaflib/waflib/extras/run_do_script.py
2019-10-21T13:06:45.6512070Z  create mode 100644 .mywaflib/waflib/extras/run_jl_script.py
2019-10-21T13:06:45.6512200Z  create mode 100755 .mywaflib/waflib/extras/run_m_script.py
2019-10-21T13:06:45.6512270Z  create mode 100755 .mywaflib/waflib/extras/run_pl_script.py
2019-10-21T13:06:45.6512380Z  create mode 100755 .mywaflib/waflib/extras/run_py_script.py
2019-10-21T13:06:45.6512450Z  create mode 100755 .mywaflib/waflib/extras/run_r_script.py
2019-10-21T13:06:45.6512560Z  create mode 100755 .mywaflib/waflib/extras/sas.py
2019-10-21T13:06:45.6512630Z  create mode 100755 .mywaflib/waflib/extras/satellite_assembly.py
2019-10-21T13:06:45.6512750Z  create mode 100755 .mywaflib/waflib/extras/scala.py
2019-10-21T13:06:45.6512820Z  create mode 100755 .mywaflib/waflib/extras/slow_qt4.py
2019-10-21T13:06:45.6512930Z  create mode 100755 .mywaflib/waflib/extras/softlink_libs.py
2019-10-21T13:06:45.6513010Z  create mode 100755 .mywaflib/waflib/extras/sphinx_build.py
2019-10-21T13:06:45.6513110Z  create mode 100755 .mywaflib/waflib/extras/stale.py
2019-10-21T13:06:45.6513480Z  create mode 100755 .mywaflib/waflib/extras/stracedeps.py
2019-10-21T13:06:45.6513600Z  create mode 100755 .mywaflib/waflib/extras/swig.py
2019-10-21T13:06:45.6513670Z  create mode 100755 .mywaflib/waflib/extras/syms.py
2019-10-21T13:06:45.6513770Z  create mode 100755 .mywaflib/waflib/extras/ticgt.py
2019-10-21T13:06:45.6513840Z  create mode 100755 .mywaflib/waflib/extras/unity.py
2019-10-21T13:06:45.6513940Z  create mode 100755 .mywaflib/waflib/extras/use_config.py
2019-10-21T13:06:45.6514010Z  create mode 100755 .mywaflib/waflib/extras/valadoc.py
2019-10-21T13:06:45.6514110Z  create mode 100755 .mywaflib/waflib/extras/waf_xattr.py
2019-10-21T13:06:45.6514180Z  create mode 100755 .mywaflib/waflib/extras/why.py
2019-10-21T13:06:45.6514280Z  create mode 100755 .mywaflib/waflib/extras/win32_opts.py
2019-10-21T13:06:45.6514350Z  create mode 100755 .mywaflib/waflib/extras/wix.py
2019-10-21T13:06:45.6514480Z  create mode 100755 .mywaflib/waflib/extras/write_project_headers.py
2019-10-21T13:06:45.6514560Z  create mode 100755 .mywaflib/waflib/extras/xcode6.py
2019-10-21T13:06:45.6514660Z  create mode 100755 .mywaflib/waflib/fixpy2.py
2019-10-21T13:06:45.6514730Z  create mode 100755 .mywaflib/waflib/processor.py
2019-10-21T13:06:45.6515700Z  create mode 100644 .pre-commit-config.yaml
2019-10-21T13:06:45.6515780Z  create mode 100755 LICENSE
2019-10-21T13:06:45.6515890Z  create mode 100755 environment.yml
2019-10-21T13:06:45.6515960Z  create mode 100755 src/__init__.py
2019-10-21T13:06:45.6516370Z  create mode 100755 src/analysis/__init__.py
2019-10-21T13:06:45.6516460Z  create mode 100755 src/analysis/schelling.py
2019-10-21T13:06:45.6516550Z  create mode 100755 src/analysis/wscript
2019-10-21T13:06:45.6516620Z  create mode 100755 src/data_management/__init__.py
2019-10-21T13:06:45.6516720Z  create mode 100755 src/data_management/get_simulation_draws.py
2019-10-21T13:06:45.6516810Z  create mode 100755 src/data_management/wscript
2019-10-21T13:06:45.6516900Z  create mode 100755 src/documentation/analysis.rst
2019-10-21T13:06:45.6516980Z  create mode 100755 src/documentation/conf.py
2019-10-21T13:06:45.6517150Z  create mode 100755 src/documentation/data_management.rst
2019-10-21T13:06:45.6517230Z  create mode 100755 src/documentation/final.rst
2019-10-21T13:06:45.6517290Z  create mode 100755 src/documentation/index.rst
2019-10-21T13:06:45.6517400Z  create mode 100755 src/documentation/introduction.rst
2019-10-21T13:06:45.6517470Z  create mode 100755 src/documentation/library.rst
2019-10-21T13:06:45.6517560Z  create mode 100755 src/documentation/model_code.rst
2019-10-21T13:06:45.6517630Z  create mode 100755 src/documentation/model_specs.rst
2019-10-21T13:06:45.6517740Z  create mode 100755 src/documentation/original_data.rst
2019-10-21T13:06:45.6517810Z  create mode 100755 src/documentation/paper.rst
2019-10-21T13:06:45.6517900Z  create mode 100755 src/documentation/references.rst
2019-10-21T13:06:45.6518210Z  create mode 100755 src/documentation/wscript
2019-10-21T13:06:45.6518340Z  create mode 100755 src/final/__init__.py
2019-10-21T13:06:45.6518400Z  create mode 100755 src/final/plot_locations.py
2019-10-21T13:06:45.6518510Z  create mode 100755 src/final/project_dependency_graph.py
2019-10-21T13:06:45.6518570Z  create mode 100755 src/final/wscript
2019-10-21T13:06:45.6518670Z  create mode 100755 src/library/__init__.py
2019-10-21T13:06:45.6518740Z  create mode 100644 src/library/wscript
2019-10-21T13:06:45.6518840Z  create mode 100755 src/model_code/__init__.py
2019-10-21T13:06:45.6518910Z  create mode 100755 src/model_code/agent.py
2019-10-21T13:06:45.6519010Z  create mode 100755 src/model_specs/baseline.json
2019-10-21T13:06:45.6519080Z  create mode 100755 src/model_specs/max_moves_2.json
2019-10-21T13:06:45.6519170Z  create mode 100644 src/original_data/dummy.txt
2019-10-21T13:06:45.6519240Z  create mode 100755 src/paper/formulas/decision_rule.tex
2019-10-21T13:06:45.6519350Z  create mode 100644 src/paper/refs.bib
2019-10-21T13:06:45.6519410Z  create mode 100755 src/paper/research_paper.tex
2019-10-21T13:06:45.6519810Z  create mode 100755 src/paper/research_pres_30min.tex
2019-10-21T13:06:45.6519880Z  create mode 100755 src/paper/wscript
2019-10-21T13:06:45.6519970Z  create mode 100755 src/sandbox/few_agents.ipynb
2019-10-21T13:06:45.6520040Z  create mode 100755 src/wscript
2019-10-21T13:06:45.6520130Z  create mode 100755 waf.py
2019-10-21T13:06:45.6520190Z  create mode 100755 wscript
2019-10-21T13:06:45.6520290Z =============================== warnings summary ===============================
2019-10-21T13:06:45.6520370Z tests/test_pre_commit.py::test_pre_commit_python_sphinx
2019-10-21T13:06:45.6520510Z   /Users/vsts/agent/2.158.0/work/1/s/tests/test_pre_commit.py:30: PytestAssertRewriteWarning: asserting the value None, please use "assert is None"
2019-10-21T13:06:45.6520600Z     assert re.search(
2019-10-21T13:06:45.6520640Z 
2019-10-21T13:06:45.6520740Z tests/test_waf.py::test_waf_configure_stata
2019-10-21T13:06:45.6520810Z tests/test_waf.py::test_waf_configure_matlab
2019-10-21T13:06:45.6520920Z tests/test_waf.py::test_waf_configure_julia
2019-10-21T13:06:45.6521010Z   /Users/vsts/agent/2.158.0/work/1/s/tests/test_waf.py:26: PytestAssertRewriteWarning: asserting the value None, please use "assert is None"
2019-10-21T13:06:45.6521580Z     assert re.search(r"configure\\?[\'\"] finished successfully", str(log_configure))
2019-10-21T13:06:45.6521660Z 
2019-10-21T13:06:45.6521770Z tests/test_waf.py::test_waf_build_stata
2019-10-21T13:06:45.6521840Z tests/test_waf.py::test_waf_build_matlab
2019-10-21T13:06:45.6521930Z tests/test_waf.py::test_waf_build_julia
2019-10-21T13:06:45.6522020Z   /Users/vsts/agent/2.158.0/work/1/s/tests/test_waf.py:37: PytestAssertRewriteWarning: asserting the value None, please use "assert is None"
2019-10-21T13:06:45.6522520Z     assert re.search(r"build\\?[\'\"] finished successfully", str(log_build))
2019-10-21T13:06:45.6522590Z 
2019-10-21T13:06:45.6523000Z -- Docs: https://docs.pytest.org/en/latest/warnings.html
2019-10-21T13:06:45.6523140Z ======= 1 failed, 20 passed, 6 xfailed, 7 warnings in 382.29s (0:06:22) ========
2019-10-21T13:06:45.7609880Z ##[error]Bash exited with code '1'.
2019-10-21T13:06:45.7665740Z ##[section]Finishing: Run pytests.
```



Discussion:
can you include the contents of the log?
hmmm! reading the code there does appear to be a very rare race there -- it's an easy fix let me throw together a PR for it

Resolving patch:
diff --git a/pre_commit/store.py b/pre_commit/store.py
--- a/pre_commit/store.py
+++ b/pre_commit/store.py
@@ -13,6 +13,7 @@
 from pre_commit.util import CalledProcessError
 from pre_commit.util import clean_path_on_failure
 from pre_commit.util import cmd_output_b
+from pre_commit.util import mkdirp
 from pre_commit.util import resource_text
 from pre_commit.util import rmtree
 
@@ -41,7 +42,7 @@ def __init__(self, directory=None):
         self.db_path = os.path.join(self.directory, 'db.db')
 
         if not os.path.exists(self.directory):
-            os.makedirs(self.directory)
+            mkdirp(self.directory)
             with io.open(os.path.join(self.directory, 'README'), 'w') as f:
                 f.write(
                     'This directory is maintained by the pre-commit project.\n'


Test patch: