when can `ensurepip` step in `export` ever fail? I...
# general
b
when can
ensurepip
step in
export
ever fail? I'm getting error when exporting to venv, just says ensurepip ended with non zero exit. When I check venv out I actually see there's pip module missing so there's that. It doesn't give any other useful error message to check what's going wrong. I can do
pants repl
just fine.
h
Which pants version is this? And what is the full output? (with --print-exception-stacktrace turned on)
b
Copy code
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/ubuntu/.pex/unzipped_pexes/2aac9312154c299fac910874b778e800dca4c62a/__main__.py", line 103, in <module>
    bootstrap_pex(__entry_point__, execute=__execute__, venv_dir=__venv_dir__)
  File "/home/ubuntu/.pex/unzipped_pexes/2aac9312154c299fac910874b778e800dca4c62a/.bootstrap/pex/pex_bootstrapper.py", line 601, in bootstrap_pex
    pex.PEX(entry_point).execute()
  File "/home/ubuntu/.pex/unzipped_pexes/2aac9312154c299fac910874b778e800dca4c62a/.bootstrap/pex/pex.py", line 540, in execute
    sys.exit(self._wrap_coverage(self._wrap_profiling, self._execute))
  File "/home/ubuntu/.pex/unzipped_pexes/2aac9312154c299fac910874b778e800dca4c62a/.bootstrap/pex/pex.py", line 447, in _wrap_coverage
    return runner(*args)
  File "/home/ubuntu/.pex/unzipped_pexes/2aac9312154c299fac910874b778e800dca4c62a/.bootstrap/pex/pex.py", line 478, in _wrap_profiling
    return runner(*args)
  File "/home/ubuntu/.pex/unzipped_pexes/2aac9312154c299fac910874b778e800dca4c62a/.bootstrap/pex/pex.py", line 561, in _execute
    return self.execute_entry(
  File "/home/ubuntu/.pex/unzipped_pexes/2aac9312154c299fac910874b778e800dca4c62a/.bootstrap/pex/pex.py", line 751, in execute_entry
    return self.execute_module(entry_point.module)
  File "/home/ubuntu/.pex/unzipped_pexes/2aac9312154c299fac910874b778e800dca4c62a/.bootstrap/pex/pex.py", line 759, in execute_module
    runpy.run_module(module_name, run_name="__main__", alter_sys=True)
  File "/usr/lib/python3.10/runpy.py", line 224, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/ubuntu/.pex/installed_wheels/d70444dc4c636a154fc77836d81e657d7ad8d148f2baee61c6a62095ecf3d504/pex-2.1.102-py2.py3-none-any.whl/pex/tools/__main__.py", line 10, in <module>
    sys.exit(tools())
  File "/home/ubuntu/.pex/installed_wheels/d70444dc4c636a154fc77836d81e657d7ad8d148f2baee61c6a62095ecf3d504/pex-2.1.102-py2.py3-none-any.whl/pex/tools/main.py", line 92, in main
    result = catch(pex_command.run, pex)
  File "/home/ubuntu/.pex/installed_wheels/d70444dc4c636a154fc77836d81e657d7ad8d148f2baee61c6a62095ecf3d504/pex-2.1.102-py2.py3-none-any.whl/pex/result.py", line 103, in catch
    return func(*args, **kwargs)
  File "/home/ubuntu/.pex/installed_wheels/d70444dc4c636a154fc77836d81e657d7ad8d148f2baee61c6a62095ecf3d504/pex-2.1.102-py2.py3-none-any.whl/pex/tools/commands/venv.py", line 202, in run
    venv.install_pip()
  File "/home/ubuntu/.pex/installed_wheels/d70444dc4c636a154fc77836d81e657d7ad8d148f2baee61c6a62095ecf3d504/pex-2.1.102-py2.py3-none-any.whl/pex/venv/virtualenv.py", line 353, in install_pip
    self._interpreter.execute(args=["-m", "ensurepip", "-U", "--default-pip"])
  File "/home/ubuntu/.pex/installed_wheels/d70444dc4c636a154fc77836d81e657d7ad8d148f2baee61c6a62095ecf3d504/pex-2.1.102-py2.py3-none-any.whl/pex/interpreter.py", line 1234, in execute
    stdout, stderr = Executor.execute(cmd, stdin_payload=stdin_payload, env=env, **kwargs)
  File "/home/ubuntu/.pex/installed_wheels/d70444dc4c636a154fc77836d81e657d7ad8d148f2baee61c6a62095ecf3d504/pex-2.1.102-py2.py3-none-any.whl/pex/executor.py", line 99, in execute
    raise cls.NonZeroExit(cmd, process.returncode, stdout, stderr)
pex.executor.Executor.NonZeroExit: received exit code 1 during execution of `['/home/ubuntu/agx/dist/export/python/virtualenv/3.10.6/bin/python3.10', '-s', '-E', '-m', 'ensurepip', '-U', '--default-pip']` while trying to execute `['/home/ubuntu/agx/dist/export/python/virtualenv/3.10.6/bin/python3.10', '-s', '-E', '-m', 'ensurepip', '-U', '--default-pip']`
17:53:58.07 [ERROR] 1 Exception encountered:

Engine traceback:
  in select
  in pants.core.goals.export.export
Traceback (most recent call last):
  File "/home/ubuntu/.cache/pants/setup/bootstrap-Linux-x86_64/2.13.0_py39/lib/python3.9/site-packages/pants/engine/internals/selectors.py", line 653, in native_engine_generator_send
    res = func.send(arg)
  File "/home/ubuntu/.cache/pants/setup/bootstrap-Linux-x86_64/2.13.0_py39/lib/python3.9/site-packages/pants/core/goals/export.py", line 142, in export
    raise ExportError(f"Failed to write {result.description} to {result_dir}")
pants.core.goals.export.ExportError: Failed to write virtualenv (using Python 3.10.6) to dist/export/python/virtualenv
I'm on 2.13.0. --print-exception-stacktrace wasn't good for
export
so used
--print-stacktrace
, but its not really giving us much
but the problem is gone now as we've merged in new changes and requirement updates. Can't really pin point to what the offending requirement entry was. Next time I see it, I'll report it again
h
I misspoke, it is indeed `--print-stacktrace`…
I don’t know what could cause that, let us know if it happens again
BTW in 2.14.0 you can use
--symlink-python-virtualenv
to get a much faster
export
that doesn’t
ensurepip
and symlinks directly to an internal, immutable venv
And in 2.15.0 there will be some more improvements to
export
, such as explicitly listing the resolves you want to export, so you don’t get all sorts of tools you don’t want