kareman / SwiftShell

A Swift framework for shell scripting.
https://kareman.github.io/SwiftShell
MIT License
1.03k stars 87 forks source link

gradlew taking forever when run from terminal #66

Closed salmatarzi closed 6 years ago

salmatarzi commented 6 years ago

This is a Sample Project for this issue: https://github.com/salmatarzi/SampleProject/

Expected Behaviour

Running commandlinetool clean from the terminal from the directory of the Android project to run correctly and terminate.

Actual Behaviour

The command takes forever when running the command from the terminal, however when running it from XCode, it runs perfectly fine, and cleans the Android project

Steps to reproduce

Run commandlinetool clean from the terminal from the directory of the Android project

kareman commented 6 years ago

Hi, does this only happen when you try to run "./gradlew clean" using SwiftShell, or does it happen with other commands too? I've never used gradle, I tried installing it in a Parallels VM to test this but I only get the error message "Could not determine java version from '10.0.2'.".

salmatarzi commented 6 years ago

@kareman This happens whenever I try to use ./gradlew command in general, it doesn't happen with other commands though.

kareman commented 6 years ago

Ok, can you try these and see if there is any difference?

echo a | commandlinetool clean
commandlinetool clean | more

You say it takes forever when running from the terminal, does this mean it works, but takes a very long time, or does it never finish? Also, when you run ./gradlew clean in the terminal, does it ask for input from the keyboard?

salmatarzi commented 6 years ago

@kareman

can you try these and see if there is any difference?

The first one worked, terminated and cleaned the project, the second one stayed idle for quite some time not terminating.

You say it takes forever when running from the terminal, does this mean it works, but takes a very long time, or does it never finish?

Yes, it never finishes

Also, when you run ./gradlew clean in the terminal, does it ask for input from the keyboard?

No, it doesn't ask for any input

kareman commented 6 years ago

I think the problem is gradlew does things differently when standard input is a terminal session. I have seen similar problems before. Try using try "".runAndPrint("./gradlew", "clean") in CleanCommand.swift to change standard input to an empty stream.

salmatarzi commented 6 years ago

@kareman This worked! Thank you so much 🙏🏽

kareman commented 6 years ago

Glad to hear it. Good luck with the project :)