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

Fix error message when the cwd directory does not exist #174

Merged
merged 1 commit into from
Nov 3, 2023

Conversation

kzrnm
Copy link
Contributor

@kzrnm kzrnm commented Oct 17, 2023

The current implementation outputs an error executable could not be found when the cwd directory does not exist.

The error message is confusing, so I added an error when the cwd does not exist.

Behavior example

[tool.poe.tasks.cwd-ok]
cwd = ".github"
cmd = "echo ok"

[tool.poe.tasks.cwd-ng]
cwd = "notexist"
cmd = "echo ng"

Current

Ubuntu(WSL)

$ poe cwd-ok
Poe => echo ok
ok

$ poe cwd-ng
Poe => echo ng
Poe the Poet - A task runner that works well with poetry.
version 0.24.1

Error: executable 'echo' could not be found using virtualenv '/home/kzrnm/poethepoet/.venv' 

USAGE
  poe [-h] [-v | -q] [--root PATH] [--ansi | --no-ansi] task [task arguments]
....................................

Windows(Git Bash)

$ poe cwd-ok
Poe => echo ok
ok

$ poe cwd-ng
Poe => echo ng
Traceback (most recent call last):
....................................
  File "Z:\poethepoet\poethepoet\executor\base.py", line 164, in _execute_cmd
    return self._exec_via_subproc(cmd, input=input, env=env, shell=shell)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "Z:\poethepoet\poethepoet\executor\base.py", line 231, in _exec_via_subproc
    proc = Popen(cmd, **popen_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "Z:\Python311\Lib\subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "Z:\Python311\Lib\subprocess.py", line 1538, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
NotADirectoryError: [WinError 267] The directory name is invalid

New

Ubuntu(WSL)

$ poe cwd-ok
Poe => echo ok
ok

$ poe cwd-ng
Poe => echo ng
Poe the Poet - A task runner that works well with poetry.
version 0.24.1

Error: Working directory /home/kzrnm/poethepoet/notexist could not be found.

USAGE
  poe [-h] [-v | -q] [--root PATH] [--ansi | --no-ansi] task [task arguments]
....................................

@kzrnm kzrnm changed the base branch from development to main October 17, 2023 11:18
@kzrnm kzrnm changed the base branch from main to development October 17, 2023 11:22
@kzrnm
Copy link
Contributor Author

kzrnm commented Oct 17, 2023

Why did CI fail on Windows, Python 3.8?

poethepoet/executor/base.py Outdated Show resolved Hide resolved
Copy link
Owner

@nat-n nat-n left a comment

Choose a reason for hiding this comment

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

Hi @kzrnm, thanks for the PR! I'd also spotted this issue (introduced the latest release), but hadn't pushed a fix yet 😅

@nat-n nat-n merged commit e326a24 into nat-n:development Nov 3, 2023
16 checks passed
@kzrnm kzrnm deleted the fix/cwd_not_found branch November 4, 2023 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants