nat-n / poethepoet

A task runner that works well with poetry.
https://poethepoet.natn.io/
MIT License
1.4k stars 58 forks source link

Poe is not finding the `*.cmd` executables on Windows #119

Closed ni-fgenois closed 1 year ago

ni-fgenois commented 1 year ago

First of all, thank you for maintaining this really cool tool!

Current behavior

On Windows, the following task fails to run as it can't find npm.cmd:

[tool.poe.tasks.my-node-command]
sequence = [
    {cmd="npm install"}
]

Specifying {cmd="npm.cmd install"} works fine, and {cmd="node --help"} also works as node.exe is in the path.

Expected behavior

poethepoet should call *.cmd files as if they were regular executables.

Workaround

Use a switch command

[tool.poe.tasks.my-node-command]
control.expr = "sys.platform"
[[tool.poe.tasks.my-node-command.switch]]
case = "win32"
sequence = [
    {cmd="npm.cmd install"},
]
[[tool.poe.tasks.my-node-command.switch]]
sequence = [
    {cmd="npm install"},
]
nat-n commented 1 year ago

hi @ni-fgenois, thanks for the feedback and sorry for the delayed response.

My knowledge of windows is not strong, but I understand that normally the shell uses PATHEXT when searching the path for executables, but apparently the same thing doesn't work reliably when the cmd is run as a subprocess with Popen?

I guess the desirable behaviour would be if on windows it first tried to resolve the executable from the path using shutil.where? Would that work? Is that a good idea? Is there something else going on here that might contribute to the behaviour not being as expected?

Happy to take advice on this one.

nat-n commented 1 year ago

Hi @ni-fgenois,

I think I might have a fix for this in form of https://github.com/nat-n/poethepoet/commit/98d8a85dd1dccdc8054510037cc032e0899b6dc8, but I don't have a windows machine handy to test it.

Could you help me by checking if it works as expected now with the latest pre-release? https://pypi.org/project/poethepoet/0.18.2b2/

nat-n commented 1 year ago

@ni-fgenois The fix was shipped in 0.19.0 🙂

ni-fgenois commented 1 year ago

Really sorry for the late reply, I was off on sabbatical for a few months :S

I can confirm that @ameily 's fix solves my issue too, but unfortunately not the original fix.

@nat-n could you ship a new version with the aforementioned fix?

Thanks a lot for looking into this!

nat-n commented 1 year ago

@ni-fgenois good timing, I just shipped @ameily 's fix in 0.20.0