-
Notifications
You must be signed in to change notification settings - Fork 131
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
script hangs terminal #355
Comments
sorry, but i won't be able to investigate this one as i'm not going to install all that and i do not develop on windows at all. |
Understood. I can work around it in the meantime by launching If you have any tips to like where in the source code to look at that might cause a hang, maybe I'll take a look down the road. Not a high priority for me either though since the workaround is fine |
scripts are executed in the command.rs and it is using another library run_script (also mine) which creates a script file and executes it. |
started doing a bit of sleuthing and was able to recreate the bug in a local project using just |
OK as noted over in run_script - the issue isn't windows or npx, but rather what I'm launching (webpack-dev-server) is a server that just hangs around and expects to be killed with control-c Can there be an option in In this case, The output from the command can't easily be captured this way - but that's fine. It gets shown on the terminal as usual anyway |
Yup! The same problem happens with any other command that hangs around. For example, assuming [tasks.foo]
script = ["watchexec \"echo foo\""]
|
i use cargo watch on linux and cntl c works ok there. |
on windows internal watch works fine, but external does not. for example, script1 and script2 hang, but script3 is totally fine: [tasks.script1]
script = ["watchexec \"echo foo\""]
[tasks.script2]
script = ["cargo watch -s \"echo foo\""]
[tasks.script3]
script = ["echo foo"]
watch = true However you're launching cargo watch internally... can that be used to launch arbitrary scripts the same way? |
so it's not just the internal
|
thanks for the investigation.
to workaround that what you can do is [tasks.npx.windows] which makes cargo make run it as a command. |
Thanks, will keep that in mind as another workaround :) But... I found the solution! though I don't understand enough about In the from this:
to this:
The way I ended up there is looking at command, it calls
(first arg is pipe, not inherit) Is this okay - for scripts to also use pipe() instead of inherit() for stdin? (I don't know what all the implications are here... just kinda saying things without real understanding. sorry!) |
Another interesting data point... for some reason the Good news is though that I tested on a local fork the above suggested change to
|
cool. so open a pr for run script please. |
Done. Goodnight :D |
Hello, I think I may be seeing this same issue on cargo-make 0.26.2 from crates.io. This version should include run_script 0.6 with the chage stdin to piped commit. I'm on Linux x86_64. I've tried a few of the above suggestions to create a task that launches GDB to debug a Rust program. You can see a small dummy project here: https://github.com/mogenson/cargo-make-ctrl-c GDB uses CtrlC to halt the execution of a program. In a normal shell, such as Is it possible to run a command or script in a new session, attached to the same TTY, and wait until the command or script has finished? Something similar to the setsid Linux command. |
By the way, when using the setsid command in any tasks, they fail with |
the changes in run script are not used by cargo make. i need to think of how to enable them when needed, probably some flag or something similar |
I found a workaround by abusing the script command. I've updated my dummy project with an example. I'll keep an eye out for a cargo-make update with a flag or option, since that will be a lot less hacky. |
@dakom @mogenson I updated the 0.26.3 development branch with the fix (i hope). [tasks.force-pipe-stdin]
env = { CARGO_MAKE_SCRIPT_FORCE_PIPE_STDIN = true }
script = [
'''
echo start
sleep 20
echo end
'''
] can you please validate this fix and tell me if it solves it? |
I installed the 0.26.3 branch. Unfortunately, with your above If I use the environment flag in my GDB example, the task ends immediatly after launching GDB. It does not wait for the process to finish.
|
Can't check today but will try tomorrow... in the meantime, thanks :) |
sorry about the delay... good news, this does fix it - thanks so much!! little test repo here: https://github.com/dakom/cargo-make-stdio-test |
@mogenson i'm not using my fix in your use case. |
@sagiegurari this is the workflow I've been testing:
For comparison, if you run GDB without cargo-make via |
ok thanks for the detailed explanation. will try it. |
If GDB is kind of a niche case, I've tried the following cargo make task:
As-is, pressing ctrl-c to exit cat also exits cargo-make and you don't see the last echo. With the env option uncommented, cat does not wait for stdin and the task finishes immediately. |
Describe the bug
Running a task that launches
npx webpack-dev-server
causes a hang in windows when exitingTo Reproduce
cargo make
...cargo make webpack-development-server
Error Stack
None - it's just that the terminal becomes unusable
The text was updated successfully, but these errors were encountered: