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

entrypoints.py: check if expected_executable exists #11425

Closed
wants to merge 1 commit into from

Conversation

milahu
Copy link

@milahu milahu commented Aug 30, 2022

in rare cases, python cannot call pip, and prints a stack trace.
not a fatal error

problem:
os.path.samefile can throw FileNotFoundError, when expected_executable does not exist

example debug output:

debug: exe_are_in_PATH = True
debug: binary_prefix = /nix/store/6v602p5l3c05iiq7jx8y0rjwiv2n8hhj-python3-3.9.13/bin
debug: exe_name = pip
debug: found_executable = /nix/store/bn2i33wra8x54ax33l5dnrsfghx46ky7-python3-3.9.13-env/bin/pip
debug: expected_executable = /nix/store/6v602p5l3c05iiq7jx8y0rjwiv2n8hhj-python3-3.9.13/bin/pip
debug: return: exe_name = pip

relevant call stack:

  • pip/_internal/self_outdated_check.py
  • pip/_internal/utils/entrypoints.py
Traceback
Traceback (most recent call last):
  File "/nix/store/bn2i33wra8x54ax33l5dnrsfghx46ky7-python3-3.9.13-env/lib/python3.9/site-packages/pip/_internal/utils/logging.py", line 177, in emit
    self.console.print(renderable, overflow="ignore", crop=False, style=style)
  File "/nix/store/bn2i33wra8x54ax33l5dnrsfghx46ky7-python3-3.9.13-env/lib/python3.9/site-packages/pip/_vendor/rich/console.py", line 1752, in print
    extend(render(renderable, render_options))
  File "/nix/store/bn2i33wra8x54ax33l5dnrsfghx46ky7-python3-3.9.13-env/lib/python3.9/site-packages/pip/_vendor/rich/console.py", line 1390, in render
    for render_output in iter_render:
  File "/nix/store/bn2i33wra8x54ax33l5dnrsfghx46ky7-python3-3.9.13-env/lib/python3.9/site-packages/pip/_internal/utils/logging.py", line 134, in __rich_console__
    for line in lines:
  File "/nix/store/bn2i33wra8x54ax33l5dnrsfghx46ky7-python3-3.9.13-env/lib/python3.9/site-packages/pip/_vendor/rich/segment.py", line 245, in split_lines
    for segment in segments:
  File "/nix/store/bn2i33wra8x54ax33l5dnrsfghx46ky7-python3-3.9.13-env/lib/python3.9/site-packages/pip/_vendor/rich/console.py", line 1368, in render
    renderable = rich_cast(renderable)
  File "/nix/store/bn2i33wra8x54ax33l5dnrsfghx46ky7-python3-3.9.13-env/lib/python3.9/site-packages/pip/_vendor/rich/protocol.py", line 36, in rich_cast
    renderable = cast_method()
  File "/nix/store/bn2i33wra8x54ax33l5dnrsfghx46ky7-python3-3.9.13-env/lib/python3.9/site-packages/pip/_internal/self_outdated_check.py", line 130, in __rich__
    pip_cmd = get_best_invocation_for_this_pip()
  File "/nix/store/bn2i33wra8x54ax33l5dnrsfghx46ky7-python3-3.9.13-env/lib/python3.9/site-packages/pip/_internal/utils/entrypoints.py", line 63, in get_best_invocation_for_this_pip
    if found_executable and os.path.samefile(
  File "/nix/store/6v602p5l3c05iiq7jx8y0rjwiv2n8hhj-python3-3.9.13/lib/python3.9/genericpath.py", line 101, in samefile
    s2 = os.stat(f2)
FileNotFoundError: [Errno 2] No such file or directory: '/nix/store/6v602p5l3c05iiq7jx8y0rjwiv2n8hhj-python3-3.9.13/bin/pip'
Call stack:
  File "/nix/store/6v602p5l3c05iiq7jx8y0rjwiv2n8hhj-python3-3.9.13/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/nix/store/6v602p5l3c05iiq7jx8y0rjwiv2n8hhj-python3-3.9.13/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/nix/store/bn2i33wra8x54ax33l5dnrsfghx46ky7-python3-3.9.13-env/lib/python3.9/site-packages/pip/__main__.py", line 31, in <module>
    sys.exit(_main())
  File "/nix/store/bn2i33wra8x54ax33l5dnrsfghx46ky7-python3-3.9.13-env/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 70, in main
    return command.main(cmd_args)
  File "/nix/store/bn2i33wra8x54ax33l5dnrsfghx46ky7-python3-3.9.13-env/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 101, in main
    return self._main(args)
  File "/nix/store/bn2i33wra8x54ax33l5dnrsfghx46ky7-python3-3.9.13-env/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 223, in _main
    self.handle_pip_version_check(options)
  File "/nix/store/bn2i33wra8x54ax33l5dnrsfghx46ky7-python3-3.9.13-env/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 148, in handle_pip_version_check
    pip_self_version_check(session, options)
  File "/nix/store/bn2i33wra8x54ax33l5dnrsfghx46ky7-python3-3.9.13-env/lib/python3.9/site-packages/pip/_internal/self_outdated_check.py", line 237, in pip_self_version_check
    logger.info("[present-rich] %s", upgrade_prompt)
  File "/nix/store/6v602p5l3c05iiq7jx8y0rjwiv2n8hhj-python3-3.9.13/lib/python3.9/logging/__init__.py", line 1446, in info
    self._log(INFO, msg, args, **kwargs)
  File "/nix/store/6v602p5l3c05iiq7jx8y0rjwiv2n8hhj-python3-3.9.13/lib/python3.9/logging/__init__.py", line 1589, in _log
    self.handle(record)
  File "/nix/store/6v602p5l3c05iiq7jx8y0rjwiv2n8hhj-python3-3.9.13/lib/python3.9/logging/__init__.py", line 1599, in handle
    self.callHandlers(record)
  File "/nix/store/6v602p5l3c05iiq7jx8y0rjwiv2n8hhj-python3-3.9.13/lib/python3.9/logging/__init__.py", line 1661, in callHandlers
    hdlr.handle(record)
  File "/nix/store/6v602p5l3c05iiq7jx8y0rjwiv2n8hhj-python3-3.9.13/lib/python3.9/logging/__init__.py", line 952, in handle
    self.emit(record)
  File "/nix/store/bn2i33wra8x54ax33l5dnrsfghx46ky7-python3-3.9.13-env/lib/python3.9/site-packages/pip/_internal/utils/logging.py", line 179, in emit
    self.handleError(record)
Message: '[present-rich] %s'
Arguments: (UpgradePrompt(old='22.1.2', new='22.2.2'),)

@domdfcoding
Copy link
Contributor

I think this is the same issue as #11309, which has a PR already (#11318)

@github-actions github-actions bot added the needs rebase or merge PR has conflicts with current master label Aug 31, 2022
@milahu
Copy link
Author

milahu commented Aug 31, 2022

yes, thanks : )

@milahu milahu closed this Aug 31, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs rebase or merge PR has conflicts with current master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants