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

Cargo (custom) runner can't execute python scripts on windows #8347

Closed
jschwe opened this issue Jun 9, 2020 · 2 comments
Closed

Cargo (custom) runner can't execute python scripts on windows #8347

jschwe opened this issue Jun 9, 2020 · 2 comments
Labels
C-bug Category: bug

Comments

@jschwe
Copy link
Contributor

jschwe commented Jun 9, 2020

Problem

On windows cargo fails to execute a python script that is defined as a runner for a target in .cargo/config
This happens both when using cygwin and powershell to call cargo.
Here is a minimal example: https://github.com/jschwe/cargo_windows_python_test_runner_bug_example
The error produced by cargo is: could not execute process `C:\Users\jschw\CLionProjects\python_runner\tests/runner.py C:\Users\jschw\CLionProjects\python_runner\target\debug\dep s\integration_test-27f6506d67a39760.exe` (never executed)

The script contains a shebang which obviously works fine on unix, but it should work on windows too since .py files are registered to be executed by python. Calling the process printed in the error output directly from powershell works, on cygwin it works if you adjust the path to the cygwin path style.

Steps

  1. Use windows
  2. git clone https://github.com/jschwe/cargo_windows_python_test_runner_bug_example.git
  3. cargo test or cargo test --test integration_test

Possible Solution(s)

I don't know how cargo currently invokes the runner so I have no idea if this is a simple fix or not.

Notes
Prepending 'python3' to the runner path (e.g. runner = "python3 tests/runner.py") doesn't work (currently) either, since then the path to my script would have to be absolute.
My use case is I'm using a python script as a wrapper to run the integration tests executable in qemu and possibly parse the output.

Output of cargo version:

cargo 1.45.0-nightly (9fcb8c1 2020-05-25)

@jschwe jschwe added the C-bug Category: bug label Jun 9, 2020
@ehuss
Copy link
Contributor

ehuss commented Jun 9, 2020

Windows doesn't have native support for shebang style executables. Cargo uses the normal command execution facilities, so it is not aware of file associations or anything like that.

Why doesn't using a runner like "python3 tests/runner.py" work for you? It shouldn't need an absolute path.

@jschwe
Copy link
Contributor Author

jschwe commented Jun 9, 2020

Ah I'm sorry, it seems I confused some things and didn't look closely enough at the error message. python tests/runner.py actually does work, I just had an issue with my path since I didn't expect python3 to only be available under the python command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants