We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Commit c74a74d causes docker dev image build to fail.
Hi,

I had 1.3.13 successfully install in a docker dev environment, which fully built and installed. I decided to try the latest source in master today and this error occurred:

```
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.4
    creating build/lib.linux-x86_64-3.4/typed_ast
    copying typed_ast/ast27.py -> build/lib.linux-x86_64-3.4/typed_ast
    copying typed_ast/ast35.py -> build/lib.linux-x86_64-3.4/typed_ast
    copying typed_ast/conversions.py -> build/lib.linux-x86_64-3.4/typed_ast
    copying typed_ast/__init__.py -> build/lib.linux-x86_64-3.4/typed_ast
    running build_ext
    building '_ast27' extension
    creating build/temp.linux-x86_64-3.4
    creating build/temp.linux-x86_64-3.4/ast27
    creating build/temp.linux-x86_64-3.4/ast27/Parser
    creating build/temp.linux-x86_64-3.4/ast27/Python
    creating build/temp.linux-x86_64-3.4/ast27/Custom
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -Iast27/Include -I/usr/include/python3.4m -I/srv/zulip-venv-cache/2d0d4429f07d3367f31c904bcf110e00407cafa8/zulip-py3-venv/include/python3.4m -c ast27/Parser/acceler.c -o build/temp.linux-x86_64-3.4/ast27/Parser/acceler.o
    unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/srv/zulip-venv-cache/2d0d4429f07d3367f31c904bcf110e00407cafa8/zulip-py3-venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-u0_6ev0b/typed-ast/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-eq6ql577-record/install-record.txt --single-version-externally-managed --compile --install-headers /srv/zulip-venv-cache/2d0d4429f07d3367f31c904bcf110e00407cafa8/zulip-py3-venv/include/site/python3.4/typed-ast" failed with error code 1 in /tmp/pip-build-u0_6ev0b/typed-ast/                                                              
Traceback (most recent call last):
  File "/srv/zulip/provision.py", line 202, in <module>
    sys.exit(main())
  File "/srv/zulip/provision.py", line 153, in main
    virtualenv_args=['-p', 'python3'])
  File "/srv/zulip/scripts/lib/setup_venv.py", line 44, in setup_virtualenv
    do_setup_virtualenv(cached_venv_path, requirements_file, virtualenv_args or [])
  File "/srv/zulip/scripts/lib/setup_venv.py", line 68, in do_setup_virtualenv
    run(["pip", "install", "--no-deps", "--requirement", requirements_file])
  File "/srv/zulip/zulip_tools.py", line 78, in run
    raise subprocess.CalledProcessError(rc, args)
subprocess.CalledProcessError: Command '['pip', 'install', '--no-deps', '--requirement', '/srv/zulip/requirements/mypy.txt']' returned non-zero exit status 1
```

At the time of this writing commit https://github.com/zulip/zulip/commit/8cecb3774321adf638b93781a175e74e68a6564b is the latest version I used, so the error must have been between this commit and last commit for release 1.3.13.

When I reverted this commit https://github.com/zulip/zulip/commit/c74a74dc7427549eba4ececcf91c483ca2876796 everything compiled as normal. There must be a dependency that is pulled in that makes it work.

Hope this helps.

Jon


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `scripts/lib/setup_venv.py`
Content:
```
1 from __future__ import print_function
2 
3 import os
4 import sys
5 from os.path import dirname, abspath
6 import subprocess
7 from zulip_tools import run
8 
9 ZULIP_PATH = dirname(dirname(dirname(abspath(__file__))))
10 VENV_CACHE_PATH = "/srv/zulip-venv-cache"
11 
12 if '--travis' in sys.argv:
13     # In Travis CI, we don't have root access
14     VENV_CACHE_PATH = os.path.join(os.environ['HOME'], "zulip-venv-cache")
15 
16 if False:
17     # Don't add a runtime dependency on typing
18     from typing import List, Optional
19 
20 VENV_DEPENDENCIES = [
21     "libffi-dev",
22     "libfreetype6-dev",
23     "libldap2-dev",
24     "libmemcached-dev",
25     "postgresql-server-dev-all",
26     "python3-dev",          # Needed to install typed-ast dependency of mypy
27     "python-dev",
28     "python-virtualenv",
29 ]
30 
31 def setup_virtualenv(target_venv_path, requirements_file, virtualenv_args=None):
32     # type: (Optional[str], str, Optional[List[str]]) -> str
33 
34     # Check if a cached version already exists
35     path = os.path.join(ZULIP_PATH, 'scripts', 'lib', 'hash_reqs.py')
36     output = subprocess.check_output([path, requirements_file])
37     sha1sum = output.split()[0]
38     if target_venv_path is None:
39         cached_venv_path = os.path.join(VENV_CACHE_PATH, sha1sum, 'venv')
40     else:
41         cached_venv_path = os.path.join(VENV_CACHE_PATH, sha1sum, os.path.basename(target_venv_path))
42     success_stamp = os.path.join(cached_venv_path, "success-stamp")
43     if not os.path.exists(success_stamp):
44         do_setup_virtualenv(cached_venv_path, requirements_file, virtualenv_args or [])
45         run(["touch", success_stamp])
46 
47     print("Using cached Python venv from %s" % (cached_venv_path,))
48     if target_venv_path is not None:
49         run(["sudo", "ln", "-nsf", cached_venv_path, target_venv_path])
50     activate_this = os.path.join(cached_venv_path, "bin", "activate_this.py")
51     exec(open(activate_this).read(), {}, dict(__file__=activate_this)) # type: ignore # https://github.com/python/mypy/issues/1577
52     return cached_venv_path
53 
54 def do_setup_virtualenv(venv_path, requirements_file, virtualenv_args):
55     # type: (str, str, List[str]) -> None
56 
57     # Setup Python virtualenv
58     run(["sudo", "rm", "-rf", venv_path])
59     run(["sudo", "mkdir", "-p", venv_path])
60     run(["sudo", "chown", "{}:{}".format(os.getuid(), os.getgid()), venv_path])
61     run(["virtualenv"] + virtualenv_args + [venv_path])
62 
63     # Switch current Python context to the virtualenv.
64     activate_this = os.path.join(venv_path, "bin", "activate_this.py")
65     exec(open(activate_this).read(), {}, dict(__file__=activate_this)) # type: ignore # https://github.com/python/mypy/issues/1577
66 
67     run(["pip", "install", "--upgrade", "pip"])
68     run(["pip", "install", "--no-deps", "--requirement", requirements_file])
69
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/scripts/lib/setup_venv.py b/scripts/lib/setup_venv.py
--- a/scripts/lib/setup_venv.py
+++ b/scripts/lib/setup_venv.py
@@ -18,6 +18,7 @@
     from typing import List, Optional
 
 VENV_DEPENDENCIES = [
+    "build-essential",
     "libffi-dev",
     "libfreetype6-dev",
     "libldap2-dev",
@@ -25,6 +26,7 @@
     "postgresql-server-dev-all",
     "python3-dev",          # Needed to install typed-ast dependency of mypy
     "python-dev",
+    "python-pip",
     "python-virtualenv",
 ]

{"golden_diff": "diff --git a/scripts/lib/setup_venv.py b/scripts/lib/setup_venv.py\n--- a/scripts/lib/setup_venv.py\n+++ b/scripts/lib/setup_venv.py\n@@ -18,6 +18,7 @@\n     from typing import List, Optional\n \n VENV_DEPENDENCIES = [\n+    \"build-essential\",\n     \"libffi-dev\",\n     \"libfreetype6-dev\",\n     \"libldap2-dev\",\n@@ -25,6 +26,7 @@\n     \"postgresql-server-dev-all\",\n     \"python3-dev\",          # Needed to install typed-ast dependency of mypy\n     \"python-dev\",\n+    \"python-pip\",\n     \"python-virtualenv\",\n ]\n", "issue": "Commit c74a74d causes docker dev image build to fail.\nHi,\n\nI had 1.3.13 successfully install in a docker dev environment, which fully built and installed. I decided to try the latest source in master today and this error occurred:\n\n```\n    running install\n    running build\n    running build_py\n    creating build\n    creating build/lib.linux-x86_64-3.4\n    creating build/lib.linux-x86_64-3.4/typed_ast\n    copying typed_ast/ast27.py -> build/lib.linux-x86_64-3.4/typed_ast\n    copying typed_ast/ast35.py -> build/lib.linux-x86_64-3.4/typed_ast\n    copying typed_ast/conversions.py -> build/lib.linux-x86_64-3.4/typed_ast\n    copying typed_ast/__init__.py -> build/lib.linux-x86_64-3.4/typed_ast\n    running build_ext\n    building '_ast27' extension\n    creating build/temp.linux-x86_64-3.4\n    creating build/temp.linux-x86_64-3.4/ast27\n    creating build/temp.linux-x86_64-3.4/ast27/Parser\n    creating build/temp.linux-x86_64-3.4/ast27/Python\n    creating build/temp.linux-x86_64-3.4/ast27/Custom\n    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -Iast27/Include -I/usr/include/python3.4m -I/srv/zulip-venv-cache/2d0d4429f07d3367f31c904bcf110e00407cafa8/zulip-py3-venv/include/python3.4m -c ast27/Parser/acceler.c -o build/temp.linux-x86_64-3.4/ast27/Parser/acceler.o\n    unable to execute 'x86_64-linux-gnu-gcc': No such file or directory\n    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1\n\n    ----------------------------------------\nCommand \"/srv/zulip-venv-cache/2d0d4429f07d3367f31c904bcf110e00407cafa8/zulip-py3-venv/bin/python3 -u -c \"import setuptools, tokenize;__file__='/tmp/pip-build-u0_6ev0b/typed-ast/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))\" install --record /tmp/pip-eq6ql577-record/install-record.txt --single-version-externally-managed --compile --install-headers /srv/zulip-venv-cache/2d0d4429f07d3367f31c904bcf110e00407cafa8/zulip-py3-venv/include/site/python3.4/typed-ast\" failed with error code 1 in /tmp/pip-build-u0_6ev0b/typed-ast/                                                              \nTraceback (most recent call last):\n  File \"/srv/zulip/provision.py\", line 202, in <module>\n    sys.exit(main())\n  File \"/srv/zulip/provision.py\", line 153, in main\n    virtualenv_args=['-p', 'python3'])\n  File \"/srv/zulip/scripts/lib/setup_venv.py\", line 44, in setup_virtualenv\n    do_setup_virtualenv(cached_venv_path, requirements_file, virtualenv_args or [])\n  File \"/srv/zulip/scripts/lib/setup_venv.py\", line 68, in do_setup_virtualenv\n    run([\"pip\", \"install\", \"--no-deps\", \"--requirement\", requirements_file])\n  File \"/srv/zulip/zulip_tools.py\", line 78, in run\n    raise subprocess.CalledProcessError(rc, args)\nsubprocess.CalledProcessError: Command '['pip', 'install', '--no-deps', '--requirement', '/srv/zulip/requirements/mypy.txt']' returned non-zero exit status 1\n```\n\nAt the time of this writing commit https://github.com/zulip/zulip/commit/8cecb3774321adf638b93781a175e74e68a6564b is the latest version I used, so the error must have been between this commit and last commit for release 1.3.13.\n\nWhen I reverted this commit https://github.com/zulip/zulip/commit/c74a74dc7427549eba4ececcf91c483ca2876796 everything compiled as normal. There must be a dependency that is pulled in that makes it work.\n\nHope this helps.\n\nJon\n\n", "before_files": [{"content": "from __future__ import print_function\n\nimport os\nimport sys\nfrom os.path import dirname, abspath\nimport subprocess\nfrom zulip_tools import run\n\nZULIP_PATH = dirname(dirname(dirname(abspath(__file__))))\nVENV_CACHE_PATH = \"/srv/zulip-venv-cache\"\n\nif '--travis' in sys.argv:\n    # In Travis CI, we don't have root access\n    VENV_CACHE_PATH = os.path.join(os.environ['HOME'], \"zulip-venv-cache\")\n\nif False:\n    # Don't add a runtime dependency on typing\n    from typing import List, Optional\n\nVENV_DEPENDENCIES = [\n    \"libffi-dev\",\n    \"libfreetype6-dev\",\n    \"libldap2-dev\",\n    \"libmemcached-dev\",\n    \"postgresql-server-dev-all\",\n    \"python3-dev\",          # Needed to install typed-ast dependency of mypy\n    \"python-dev\",\n    \"python-virtualenv\",\n]\n\ndef setup_virtualenv(target_venv_path, requirements_file, virtualenv_args=None):\n    # type: (Optional[str], str, Optional[List[str]]) -> str\n\n    # Check if a cached version already exists\n    path = os.path.join(ZULIP_PATH, 'scripts', 'lib', 'hash_reqs.py')\n    output = subprocess.check_output([path, requirements_file])\n    sha1sum = output.split()[0]\n    if target_venv_path is None:\n        cached_venv_path = os.path.join(VENV_CACHE_PATH, sha1sum, 'venv')\n    else:\n        cached_venv_path = os.path.join(VENV_CACHE_PATH, sha1sum, os.path.basename(target_venv_path))\n    success_stamp = os.path.join(cached_venv_path, \"success-stamp\")\n    if not os.path.exists(success_stamp):\n        do_setup_virtualenv(cached_venv_path, requirements_file, virtualenv_args or [])\n        run([\"touch\", success_stamp])\n\n    print(\"Using cached Python venv from %s\" % (cached_venv_path,))\n    if target_venv_path is not None:\n        run([\"sudo\", \"ln\", \"-nsf\", cached_venv_path, target_venv_path])\n    activate_this = os.path.join(cached_venv_path, \"bin\", \"activate_this.py\")\n    exec(open(activate_this).read(), {}, dict(__file__=activate_this)) # type: ignore # https://github.com/python/mypy/issues/1577\n    return cached_venv_path\n\ndef do_setup_virtualenv(venv_path, requirements_file, virtualenv_args):\n    # type: (str, str, List[str]) -> None\n\n    # Setup Python virtualenv\n    run([\"sudo\", \"rm\", \"-rf\", venv_path])\n    run([\"sudo\", \"mkdir\", \"-p\", venv_path])\n    run([\"sudo\", \"chown\", \"{}:{}\".format(os.getuid(), os.getgid()), venv_path])\n    run([\"virtualenv\"] + virtualenv_args + [venv_path])\n\n    # Switch current Python context to the virtualenv.\n    activate_this = os.path.join(venv_path, \"bin\", \"activate_this.py\")\n    exec(open(activate_this).read(), {}, dict(__file__=activate_this)) # type: ignore # https://github.com/python/mypy/issues/1577\n\n    run([\"pip\", \"install\", \"--upgrade\", \"pip\"])\n    run([\"pip\", \"install\", \"--no-deps\", \"--requirement\", requirements_file])\n", "path": "scripts/lib/setup_venv.py"}], "after_files": [{"content": "from __future__ import print_function\n\nimport os\nimport sys\nfrom os.path import dirname, abspath\nimport subprocess\nfrom zulip_tools import run\n\nZULIP_PATH = dirname(dirname(dirname(abspath(__file__))))\nVENV_CACHE_PATH = \"/srv/zulip-venv-cache\"\n\nif '--travis' in sys.argv:\n    # In Travis CI, we don't have root access\n    VENV_CACHE_PATH = os.path.join(os.environ['HOME'], \"zulip-venv-cache\")\n\nif False:\n    # Don't add a runtime dependency on typing\n    from typing import List, Optional\n\nVENV_DEPENDENCIES = [\n    \"build-essential\",\n    \"libffi-dev\",\n    \"libfreetype6-dev\",\n    \"libldap2-dev\",\n    \"libmemcached-dev\",\n    \"postgresql-server-dev-all\",\n    \"python3-dev\",          # Needed to install typed-ast dependency of mypy\n    \"python-dev\",\n    \"python-pip\",\n    \"python-virtualenv\",\n]\n\ndef setup_virtualenv(target_venv_path, requirements_file, virtualenv_args=None):\n    # type: (Optional[str], str, Optional[List[str]]) -> str\n\n    # Check if a cached version already exists\n    path = os.path.join(ZULIP_PATH, 'scripts', 'lib', 'hash_reqs.py')\n    output = subprocess.check_output([path, requirements_file])\n    sha1sum = output.split()[0]\n    if target_venv_path is None:\n        cached_venv_path = os.path.join(VENV_CACHE_PATH, sha1sum, 'venv')\n    else:\n        cached_venv_path = os.path.join(VENV_CACHE_PATH, sha1sum, os.path.basename(target_venv_path))\n    success_stamp = os.path.join(cached_venv_path, \"success-stamp\")\n    if not os.path.exists(success_stamp):\n        do_setup_virtualenv(cached_venv_path, requirements_file, virtualenv_args or [])\n        run([\"touch\", success_stamp])\n\n    print(\"Using cached Python venv from %s\" % (cached_venv_path,))\n    if target_venv_path is not None:\n        run([\"sudo\", \"ln\", \"-nsf\", cached_venv_path, target_venv_path])\n    activate_this = os.path.join(cached_venv_path, \"bin\", \"activate_this.py\")\n    exec(open(activate_this).read(), {}, dict(__file__=activate_this)) # type: ignore # https://github.com/python/mypy/issues/1577\n    return cached_venv_path\n\ndef do_setup_virtualenv(venv_path, requirements_file, virtualenv_args):\n    # type: (str, str, List[str]) -> None\n\n    # Setup Python virtualenv\n    run([\"sudo\", \"rm\", \"-rf\", venv_path])\n    run([\"sudo\", \"mkdir\", \"-p\", venv_path])\n    run([\"sudo\", \"chown\", \"{}:{}\".format(os.getuid(), os.getgid()), venv_path])\n    run([\"virtualenv\"] + virtualenv_args + [venv_path])\n\n    # Switch current Python context to the virtualenv.\n    activate_this = os.path.join(venv_path, \"bin\", \"activate_this.py\")\n    exec(open(activate_this).read(), {}, dict(__file__=activate_this)) # type: ignore # https://github.com/python/mypy/issues/1577\n\n    run([\"pip\", \"install\", \"--upgrade\", \"pip\"])\n    run([\"pip\", \"install\", \"--no-deps\", \"--requirement\", requirements_file])\n", "path": "scripts/lib/setup_venv.py"}]}