We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Test suite immediately aborts with a successful exit code whenever a test that does a `pipenv run` executes
Check this out:

```python
$ time pytest
=============================================== test session starts ================================================
platform linux -- Python 3.8.10, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/jeremy/src/github.com/pypa/pipenv, configfile: setup.cfg, testpaths: tests
plugins: timeout-2.0.1, xdist-2.4.0, flaky-3.7.0, forked-1.3.0, pypi-0.1.1
collected 274 items

tests/integration/test_cli.py ...
real	7.14s
user	4.30s
sys	0.73s
$ echo $?
0
```

I know we don't have a 7 second test suite with only 3 tests in it! Also, where did pipenv's normal test summary go?

In the example above, we've run the first 3 tests of test_cli.py and the test suite aborted when running the 4th test: `test_pipenv_site_packages`. The whole test suite aborts when we get to this `pipenv run` invocation:

https://github.com/pypa/pipenv/blob/b0ebaf054e9b47fc90f6939b2473e31863da15a3/tests/integration/test_cli.py#L52

This doesn't happen in CI. It took me **forever** to figure out what's going on here. Here's the full story:

- That call to `p.pipenv` uses `click`'s [`invoke` method](https://click.palletsprojects.com/en/8.0.x/api/#click.testing.CliRunner.invoke) internally. That method internally starts executing pipenv (note that this is happening in the same python testrunner process, there is no forking going on here!)
- Eventually we get into the actual guts of `pipenv run`, which (on my Linux machine) means we execute [this call to `os.execve` in `do_run_posix`](https://github.com/pypa/pipenv/blob/b0ebaf054e9b47fc90f6939b2473e31863da15a3/pipenv/core.py#L2451-L2455). *This completely replaces the pytest process we were in the middle of*, and when the (now just pipenv) process exits, our entire test suite grinds to a halt and exits successfully. Yikes :exploding_head:!
- This doesn't happen in CI because we actually use `do_run_nt` (:interrobang:) in CI: https://github.com/pypa/pipenv/blob/b0ebaf054e9b47fc90f6939b2473e31863da15a3/pipenv/core.py#L2499-L2502. It looks like @frostming added this in https://github.com/pypa/pipenv/pull/4757/files#diff-ef852c4ac364f946819f765a6bc26f04f1b0968f31fc512949a60fa2ab0685e8R2488, presumably as a workaround for this very problem?
- (For the record, if you're running pytest with parallelism enabled, you'll see error messages like "node down: Not properly terminated" and "replacing crashed worker gw3" as the workers turn into pipenv processes and exit).

I've been able to work around this problem by explicitly setting the `CI` environment variable when running tests locally. I'll send in a PR to improve the documentation, but we might want to rework this a bit. It feels a bit off to require people to pretend to be in CI just to run tests.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pipenv/routines/shell.py`
Content:
```
1 import os
2 import subprocess
3 import sys
4 from os.path import expandvars
5 
6 from pipenv import environments
7 from pipenv.utils.project import ensure_project
8 from pipenv.utils.shell import cmd_list_to_shell, system_which
9 from pipenv.vendor import click
10 
11 
12 def do_shell(
13     project, python=False, fancy=False, shell_args=None, pypi_mirror=None, quiet=False
14 ):
15     # Ensure that virtualenv is available.
16     ensure_project(
17         project,
18         python=python,
19         validate=False,
20         pypi_mirror=pypi_mirror,
21     )
22 
23     # Support shell compatibility mode.
24     if project.s.PIPENV_SHELL_FANCY:
25         fancy = True
26 
27     from pipenv.shells import choose_shell
28 
29     shell = choose_shell(project)
30     if not quiet:
31         click.echo("Launching subshell in virtual environment...", err=True)
32 
33     fork_args = (
34         project.virtualenv_location,
35         project.project_directory,
36         shell_args,
37     )
38 
39     # Set an environment variable, so we know we're in the environment.
40     # Only set PIPENV_ACTIVE after finishing reading virtualenv_location
41     # otherwise its value will be changed
42     os.environ["PIPENV_ACTIVE"] = "1"
43 
44     if fancy:
45         shell.fork(*fork_args)
46         return
47 
48     try:
49         shell.fork_compat(*fork_args)
50     except (AttributeError, ImportError):
51         click.echo(
52             "Compatibility mode not supported. "
53             "Trying to continue as well-configured shell...",
54             err=True,
55         )
56         shell.fork(*fork_args)
57 
58 
59 def do_run(project, command, args, python=False, pypi_mirror=None):
60     """Attempt to run command either pulling from project or interpreting as executable.
61 
62     Args are appended to the command in [scripts] section of project if found.
63     """
64     from pipenv.cmdparse import ScriptEmptyError
65 
66     env = os.environ.copy()
67 
68     # Ensure that virtualenv is available.
69     ensure_project(
70         project,
71         python=python,
72         validate=False,
73         pypi_mirror=pypi_mirror,
74     )
75 
76     path = env.get("PATH", "")
77     if project.virtualenv_location:
78         new_path = os.path.join(
79             project.virtualenv_location, "Scripts" if os.name == "nt" else "bin"
80         )
81         paths = path.split(os.pathsep)
82         paths.insert(0, new_path)
83         path = os.pathsep.join(paths)
84         env["VIRTUAL_ENV"] = project.virtualenv_location
85     env["PATH"] = path
86 
87     # Set an environment variable, so we know we're in the environment.
88     # Only set PIPENV_ACTIVE after finishing reading virtualenv_location
89     # such as in inline_activate_virtual_environment
90     # otherwise its value will be changed
91     env["PIPENV_ACTIVE"] = "1"
92 
93     try:
94         script = project.build_script(command, args)
95         cmd_string = cmd_list_to_shell([script.command] + script.args)
96         if project.s.is_verbose():
97             click.echo(click.style(f"$ {cmd_string}"), err=True)
98     except ScriptEmptyError:
99         click.echo("Can't run script {0!r}-it's empty?", err=True)
100     run_args = [project, script]
101     run_kwargs = {"env": env}
102     # We're using `do_run_nt` on CI (even if we're running on a non-nt machine)
103     # as a workaround for https://github.com/pypa/pipenv/issues/4909.
104     if os.name == "nt" or environments.PIPENV_IS_CI:
105         run_fn = do_run_nt
106     else:
107         run_fn = do_run_posix
108         run_kwargs.update({"command": command})
109     run_fn(*run_args, **run_kwargs)
110 
111 
112 def do_run_posix(project, script, command, env):
113     path = env.get("PATH")
114     command_path = system_which(script.command, path=path)
115     if not command_path:
116         if project.has_script(command):
117             click.echo(
118                 "{}: the command {} (from {}) could not be found within {}."
119                 "".format(
120                     click.style("Error", fg="red", bold=True),
121                     click.style(script.command, fg="yellow"),
122                     click.style(command, bold=True),
123                     click.style("PATH", bold=True),
124                 ),
125                 err=True,
126             )
127         else:
128             click.echo(
129                 "{}: the command {} could not be found within {} or Pipfile's {}."
130                 "".format(
131                     click.style("Error", fg="red", bold=True),
132                     click.style(command, fg="yellow"),
133                     click.style("PATH", bold=True),
134                     click.style("[scripts]", bold=True),
135                 ),
136                 err=True,
137             )
138         sys.exit(1)
139     os.execve(
140         command_path,
141         [command_path, *(os.path.expandvars(arg) for arg in script.args)],
142         env,
143     )
144 
145 
146 def do_run_nt(project, script, env):
147     p = _launch_windows_subprocess(script, env)
148     p.communicate()
149     sys.exit(p.returncode)
150 
151 
152 def _launch_windows_subprocess(script, env):
153     path = env.get("PATH", "")
154     command = system_which(script.command, path=path)
155 
156     options = {"universal_newlines": True, "env": env}
157     script.cmd_args[1:] = [expandvars(arg) for arg in script.args]
158 
159     # Command not found, maybe this is a shell built-in?
160     if not command:
161         return subprocess.Popen(script.cmdify(), shell=True, **options)
162 
163     # Try to use CreateProcess directly if possible. Specifically catch
164     # Windows error 193 "Command is not a valid Win32 application" to handle
165     # a "command" that is non-executable. See pypa/pipenv#2727.
166     try:
167         return subprocess.Popen([command] + script.args, **options)
168     except OSError as e:
169         if e.winerror != 193:
170             raise
171 
172     # Try shell mode to use Windows's file association for file launch.
173     return subprocess.Popen(script.cmdify(), shell=True, **options)
174
```
--- 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/pipenv/routines/shell.py b/pipenv/routines/shell.py
--- a/pipenv/routines/shell.py
+++ b/pipenv/routines/shell.py
@@ -3,7 +3,6 @@
 import sys
 from os.path import expandvars
 
-from pipenv import environments
 from pipenv.utils.project import ensure_project
 from pipenv.utils.shell import cmd_list_to_shell, system_which
 from pipenv.vendor import click
@@ -99,9 +98,7 @@
         click.echo("Can't run script {0!r}-it's empty?", err=True)
     run_args = [project, script]
     run_kwargs = {"env": env}
-    # We're using `do_run_nt` on CI (even if we're running on a non-nt machine)
-    # as a workaround for https://github.com/pypa/pipenv/issues/4909.
-    if os.name == "nt" or environments.PIPENV_IS_CI:
+    if os.name == "nt":
         run_fn = do_run_nt
     else:
         run_fn = do_run_posix

{"golden_diff": "diff --git a/pipenv/routines/shell.py b/pipenv/routines/shell.py\n--- a/pipenv/routines/shell.py\n+++ b/pipenv/routines/shell.py\n@@ -3,7 +3,6 @@\n import sys\n from os.path import expandvars\n \n-from pipenv import environments\n from pipenv.utils.project import ensure_project\n from pipenv.utils.shell import cmd_list_to_shell, system_which\n from pipenv.vendor import click\n@@ -99,9 +98,7 @@\n         click.echo(\"Can't run script {0!r}-it's empty?\", err=True)\n     run_args = [project, script]\n     run_kwargs = {\"env\": env}\n-    # We're using `do_run_nt` on CI (even if we're running on a non-nt machine)\n-    # as a workaround for https://github.com/pypa/pipenv/issues/4909.\n-    if os.name == \"nt\" or environments.PIPENV_IS_CI:\n+    if os.name == \"nt\":\n         run_fn = do_run_nt\n     else:\n         run_fn = do_run_posix\n", "issue": "Test suite immediately aborts with a successful exit code whenever a test that does a `pipenv run` executes\nCheck this out:\r\n\r\n```python\r\n$ time pytest\r\n=============================================== test session starts ================================================\r\nplatform linux -- Python 3.8.10, pytest-6.2.5, py-1.11.0, pluggy-1.0.0\r\nrootdir: /home/jeremy/src/github.com/pypa/pipenv, configfile: setup.cfg, testpaths: tests\r\nplugins: timeout-2.0.1, xdist-2.4.0, flaky-3.7.0, forked-1.3.0, pypi-0.1.1\r\ncollected 274 items\r\n\r\ntests/integration/test_cli.py ...\r\nreal\t7.14s\r\nuser\t4.30s\r\nsys\t0.73s\r\n$ echo $?\r\n0\r\n```\r\n\r\nI know we don't have a 7 second test suite with only 3 tests in it! Also, where did pipenv's normal test summary go?\r\n\r\nIn the example above, we've run the first 3 tests of test_cli.py and the test suite aborted when running the 4th test: `test_pipenv_site_packages`. The whole test suite aborts when we get to this `pipenv run` invocation:\r\n\r\nhttps://github.com/pypa/pipenv/blob/b0ebaf054e9b47fc90f6939b2473e31863da15a3/tests/integration/test_cli.py#L52\r\n\r\nThis doesn't happen in CI. It took me **forever** to figure out what's going on here. Here's the full story:\r\n\r\n- That call to `p.pipenv` uses `click`'s [`invoke` method](https://click.palletsprojects.com/en/8.0.x/api/#click.testing.CliRunner.invoke) internally. That method internally starts executing pipenv (note that this is happening in the same python testrunner process, there is no forking going on here!)\r\n- Eventually we get into the actual guts of `pipenv run`, which (on my Linux machine) means we execute [this call to `os.execve` in `do_run_posix`](https://github.com/pypa/pipenv/blob/b0ebaf054e9b47fc90f6939b2473e31863da15a3/pipenv/core.py#L2451-L2455). *This completely replaces the pytest process we were in the middle of*, and when the (now just pipenv) process exits, our entire test suite grinds to a halt and exits successfully. Yikes :exploding_head:!\r\n- This doesn't happen in CI because we actually use `do_run_nt` (:interrobang:) in CI: https://github.com/pypa/pipenv/blob/b0ebaf054e9b47fc90f6939b2473e31863da15a3/pipenv/core.py#L2499-L2502. It looks like @frostming added this in https://github.com/pypa/pipenv/pull/4757/files#diff-ef852c4ac364f946819f765a6bc26f04f1b0968f31fc512949a60fa2ab0685e8R2488, presumably as a workaround for this very problem?\r\n- (For the record, if you're running pytest with parallelism enabled, you'll see error messages like \"node down: Not properly terminated\" and \"replacing crashed worker gw3\" as the workers turn into pipenv processes and exit).\r\n\r\nI've been able to work around this problem by explicitly setting the `CI` environment variable when running tests locally. I'll send in a PR to improve the documentation, but we might want to rework this a bit. It feels a bit off to require people to pretend to be in CI just to run tests.\n", "before_files": [{"content": "import os\nimport subprocess\nimport sys\nfrom os.path import expandvars\n\nfrom pipenv import environments\nfrom pipenv.utils.project import ensure_project\nfrom pipenv.utils.shell import cmd_list_to_shell, system_which\nfrom pipenv.vendor import click\n\n\ndef do_shell(\n    project, python=False, fancy=False, shell_args=None, pypi_mirror=None, quiet=False\n):\n    # Ensure that virtualenv is available.\n    ensure_project(\n        project,\n        python=python,\n        validate=False,\n        pypi_mirror=pypi_mirror,\n    )\n\n    # Support shell compatibility mode.\n    if project.s.PIPENV_SHELL_FANCY:\n        fancy = True\n\n    from pipenv.shells import choose_shell\n\n    shell = choose_shell(project)\n    if not quiet:\n        click.echo(\"Launching subshell in virtual environment...\", err=True)\n\n    fork_args = (\n        project.virtualenv_location,\n        project.project_directory,\n        shell_args,\n    )\n\n    # Set an environment variable, so we know we're in the environment.\n    # Only set PIPENV_ACTIVE after finishing reading virtualenv_location\n    # otherwise its value will be changed\n    os.environ[\"PIPENV_ACTIVE\"] = \"1\"\n\n    if fancy:\n        shell.fork(*fork_args)\n        return\n\n    try:\n        shell.fork_compat(*fork_args)\n    except (AttributeError, ImportError):\n        click.echo(\n            \"Compatibility mode not supported. \"\n            \"Trying to continue as well-configured shell...\",\n            err=True,\n        )\n        shell.fork(*fork_args)\n\n\ndef do_run(project, command, args, python=False, pypi_mirror=None):\n    \"\"\"Attempt to run command either pulling from project or interpreting as executable.\n\n    Args are appended to the command in [scripts] section of project if found.\n    \"\"\"\n    from pipenv.cmdparse import ScriptEmptyError\n\n    env = os.environ.copy()\n\n    # Ensure that virtualenv is available.\n    ensure_project(\n        project,\n        python=python,\n        validate=False,\n        pypi_mirror=pypi_mirror,\n    )\n\n    path = env.get(\"PATH\", \"\")\n    if project.virtualenv_location:\n        new_path = os.path.join(\n            project.virtualenv_location, \"Scripts\" if os.name == \"nt\" else \"bin\"\n        )\n        paths = path.split(os.pathsep)\n        paths.insert(0, new_path)\n        path = os.pathsep.join(paths)\n        env[\"VIRTUAL_ENV\"] = project.virtualenv_location\n    env[\"PATH\"] = path\n\n    # Set an environment variable, so we know we're in the environment.\n    # Only set PIPENV_ACTIVE after finishing reading virtualenv_location\n    # such as in inline_activate_virtual_environment\n    # otherwise its value will be changed\n    env[\"PIPENV_ACTIVE\"] = \"1\"\n\n    try:\n        script = project.build_script(command, args)\n        cmd_string = cmd_list_to_shell([script.command] + script.args)\n        if project.s.is_verbose():\n            click.echo(click.style(f\"$ {cmd_string}\"), err=True)\n    except ScriptEmptyError:\n        click.echo(\"Can't run script {0!r}-it's empty?\", err=True)\n    run_args = [project, script]\n    run_kwargs = {\"env\": env}\n    # We're using `do_run_nt` on CI (even if we're running on a non-nt machine)\n    # as a workaround for https://github.com/pypa/pipenv/issues/4909.\n    if os.name == \"nt\" or environments.PIPENV_IS_CI:\n        run_fn = do_run_nt\n    else:\n        run_fn = do_run_posix\n        run_kwargs.update({\"command\": command})\n    run_fn(*run_args, **run_kwargs)\n\n\ndef do_run_posix(project, script, command, env):\n    path = env.get(\"PATH\")\n    command_path = system_which(script.command, path=path)\n    if not command_path:\n        if project.has_script(command):\n            click.echo(\n                \"{}: the command {} (from {}) could not be found within {}.\"\n                \"\".format(\n                    click.style(\"Error\", fg=\"red\", bold=True),\n                    click.style(script.command, fg=\"yellow\"),\n                    click.style(command, bold=True),\n                    click.style(\"PATH\", bold=True),\n                ),\n                err=True,\n            )\n        else:\n            click.echo(\n                \"{}: the command {} could not be found within {} or Pipfile's {}.\"\n                \"\".format(\n                    click.style(\"Error\", fg=\"red\", bold=True),\n                    click.style(command, fg=\"yellow\"),\n                    click.style(\"PATH\", bold=True),\n                    click.style(\"[scripts]\", bold=True),\n                ),\n                err=True,\n            )\n        sys.exit(1)\n    os.execve(\n        command_path,\n        [command_path, *(os.path.expandvars(arg) for arg in script.args)],\n        env,\n    )\n\n\ndef do_run_nt(project, script, env):\n    p = _launch_windows_subprocess(script, env)\n    p.communicate()\n    sys.exit(p.returncode)\n\n\ndef _launch_windows_subprocess(script, env):\n    path = env.get(\"PATH\", \"\")\n    command = system_which(script.command, path=path)\n\n    options = {\"universal_newlines\": True, \"env\": env}\n    script.cmd_args[1:] = [expandvars(arg) for arg in script.args]\n\n    # Command not found, maybe this is a shell built-in?\n    if not command:\n        return subprocess.Popen(script.cmdify(), shell=True, **options)\n\n    # Try to use CreateProcess directly if possible. Specifically catch\n    # Windows error 193 \"Command is not a valid Win32 application\" to handle\n    # a \"command\" that is non-executable. See pypa/pipenv#2727.\n    try:\n        return subprocess.Popen([command] + script.args, **options)\n    except OSError as e:\n        if e.winerror != 193:\n            raise\n\n    # Try shell mode to use Windows's file association for file launch.\n    return subprocess.Popen(script.cmdify(), shell=True, **options)\n", "path": "pipenv/routines/shell.py"}], "after_files": [{"content": "import os\nimport subprocess\nimport sys\nfrom os.path import expandvars\n\nfrom pipenv.utils.project import ensure_project\nfrom pipenv.utils.shell import cmd_list_to_shell, system_which\nfrom pipenv.vendor import click\n\n\ndef do_shell(\n    project, python=False, fancy=False, shell_args=None, pypi_mirror=None, quiet=False\n):\n    # Ensure that virtualenv is available.\n    ensure_project(\n        project,\n        python=python,\n        validate=False,\n        pypi_mirror=pypi_mirror,\n    )\n\n    # Support shell compatibility mode.\n    if project.s.PIPENV_SHELL_FANCY:\n        fancy = True\n\n    from pipenv.shells import choose_shell\n\n    shell = choose_shell(project)\n    if not quiet:\n        click.echo(\"Launching subshell in virtual environment...\", err=True)\n\n    fork_args = (\n        project.virtualenv_location,\n        project.project_directory,\n        shell_args,\n    )\n\n    # Set an environment variable, so we know we're in the environment.\n    # Only set PIPENV_ACTIVE after finishing reading virtualenv_location\n    # otherwise its value will be changed\n    os.environ[\"PIPENV_ACTIVE\"] = \"1\"\n\n    if fancy:\n        shell.fork(*fork_args)\n        return\n\n    try:\n        shell.fork_compat(*fork_args)\n    except (AttributeError, ImportError):\n        click.echo(\n            \"Compatibility mode not supported. \"\n            \"Trying to continue as well-configured shell...\",\n            err=True,\n        )\n        shell.fork(*fork_args)\n\n\ndef do_run(project, command, args, python=False, pypi_mirror=None):\n    \"\"\"Attempt to run command either pulling from project or interpreting as executable.\n\n    Args are appended to the command in [scripts] section of project if found.\n    \"\"\"\n    from pipenv.cmdparse import ScriptEmptyError\n\n    env = os.environ.copy()\n\n    # Ensure that virtualenv is available.\n    ensure_project(\n        project,\n        python=python,\n        validate=False,\n        pypi_mirror=pypi_mirror,\n    )\n\n    path = env.get(\"PATH\", \"\")\n    if project.virtualenv_location:\n        new_path = os.path.join(\n            project.virtualenv_location, \"Scripts\" if os.name == \"nt\" else \"bin\"\n        )\n        paths = path.split(os.pathsep)\n        paths.insert(0, new_path)\n        path = os.pathsep.join(paths)\n        env[\"VIRTUAL_ENV\"] = project.virtualenv_location\n    env[\"PATH\"] = path\n\n    # Set an environment variable, so we know we're in the environment.\n    # Only set PIPENV_ACTIVE after finishing reading virtualenv_location\n    # such as in inline_activate_virtual_environment\n    # otherwise its value will be changed\n    env[\"PIPENV_ACTIVE\"] = \"1\"\n\n    try:\n        script = project.build_script(command, args)\n        cmd_string = cmd_list_to_shell([script.command] + script.args)\n        if project.s.is_verbose():\n            click.echo(click.style(f\"$ {cmd_string}\"), err=True)\n    except ScriptEmptyError:\n        click.echo(\"Can't run script {0!r}-it's empty?\", err=True)\n    run_args = [project, script]\n    run_kwargs = {\"env\": env}\n    if os.name == \"nt\":\n        run_fn = do_run_nt\n    else:\n        run_fn = do_run_posix\n        run_kwargs.update({\"command\": command})\n    run_fn(*run_args, **run_kwargs)\n\n\ndef do_run_posix(project, script, command, env):\n    path = env.get(\"PATH\")\n    command_path = system_which(script.command, path=path)\n    if not command_path:\n        if project.has_script(command):\n            click.echo(\n                \"{}: the command {} (from {}) could not be found within {}.\"\n                \"\".format(\n                    click.style(\"Error\", fg=\"red\", bold=True),\n                    click.style(script.command, fg=\"yellow\"),\n                    click.style(command, bold=True),\n                    click.style(\"PATH\", bold=True),\n                ),\n                err=True,\n            )\n        else:\n            click.echo(\n                \"{}: the command {} could not be found within {} or Pipfile's {}.\"\n                \"\".format(\n                    click.style(\"Error\", fg=\"red\", bold=True),\n                    click.style(command, fg=\"yellow\"),\n                    click.style(\"PATH\", bold=True),\n                    click.style(\"[scripts]\", bold=True),\n                ),\n                err=True,\n            )\n        sys.exit(1)\n    os.execve(\n        command_path,\n        [command_path, *(os.path.expandvars(arg) for arg in script.args)],\n        env,\n    )\n\n\ndef do_run_nt(project, script, env):\n    p = _launch_windows_subprocess(script, env)\n    p.communicate()\n    sys.exit(p.returncode)\n\n\ndef _launch_windows_subprocess(script, env):\n    path = env.get(\"PATH\", \"\")\n    command = system_which(script.command, path=path)\n\n    options = {\"universal_newlines\": True, \"env\": env}\n    script.cmd_args[1:] = [expandvars(arg) for arg in script.args]\n\n    # Command not found, maybe this is a shell built-in?\n    if not command:\n        return subprocess.Popen(script.cmdify(), shell=True, **options)\n\n    # Try to use CreateProcess directly if possible. Specifically catch\n    # Windows error 193 \"Command is not a valid Win32 application\" to handle\n    # a \"command\" that is non-executable. See pypa/pipenv#2727.\n    try:\n        return subprocess.Popen([command] + script.args, **options)\n    except OSError as e:\n        if e.winerror != 193:\n            raise\n\n    # Try shell mode to use Windows's file association for file launch.\n    return subprocess.Popen(script.cmdify(), shell=True, **options)\n", "path": "pipenv/routines/shell.py"}]}