Skip to content

Comments

fix(run): improve error when command not found#5243

Merged
finswimmer merged 1 commit intopython-poetry:masterfrom
branchv:fix/run-not-found
Feb 27, 2022
Merged

fix(run): improve error when command not found#5243
finswimmer merged 1 commit intopython-poetry:masterfrom
branchv:fix/run-not-found

Conversation

@branchv
Copy link
Member

@branchv branchv commented Feb 27, 2022

poetry run currently throws a cryptic FileNotFoundError when the command is not found on PATH. This PR adds a more succinct and hopefully more helpful error message.

Before:

$ poetry run nonexistent-command

  FileNotFoundError

  [Errno 2] No such file or directory: b'/Library/Apple/usr/bin/nonexistent-command'

  at /usr/local/Cellar/[email protected]/3.10.2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/os.py:607 in _execvpe
       603│         path_list = map(fsencode, path_list)
       604│     for dir in path_list:
       605│         fullname = path.join(dir, file)
       606│         try:
    →  607│             exec_func(fullname, *argrest)
       608│         except (FileNotFoundError, NotADirectoryError) as e:
       609│             last_exc = e
       610│         except OSError as e:
       611│             last_exc = e

After:

$ poetry run nonexistent-command
Command not found: nonexistent-command

Pull Request Check List

Resolves: #1567

  • Added tests for changed code.
  • Updated documentation for changed code.

Copy link
Member

@finswimmer finswimmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean and simple solution 👍

@finswimmer finswimmer merged commit 1d4f4a0 into python-poetry:master Feb 27, 2022
@branchv branchv deleted the fix/run-not-found branch February 27, 2022 13:02
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[1.0.0b4] poetry run fails with FileNotFoundError

2 participants