tekartik / process_run.dart

Process run helper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shell command call is causing applications crash or hangs-up.

unoravi opened this issue · comments

To execute shell commands on desktop platforms, I am using process_run dependency. Sample code as shown below.

var shell = Shell();
var res = await shell.run("ls");
print(res.outLines);

Application hangup or crash at the time of execution of second line. Please provide a latest solution for this issue. Here is the flutter doctor -v

[✓] Flutter (Channel dev, 2.1.0-10.0.pre, on Linux, locale en_GB.UTF-8)
    • Flutter version 2.1.0-10.0.pre at /home/ravi/flutter
    • Framework revision cc9b78fc5c (3 weeks ago), 2021-02-25 13:26:03 -0800
    • Engine revision a252ec09b7
    • Dart version 2.13.0 (build 2.13.0-77.0.dev)

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
    • cmake version 3.10.2
    • ninja version 1.8.2
    • pkg-config version 0.29.1

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

[✓] VS Code (version 1.52.1)
    • VS Code at /usr/share/code
    • Flutter extension version 3.20.0

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Linux
    • Chrome (web)    • chrome • web-javascript • Google Chrome 88.0.4324.146

! Doctor found issues in 2 categories.

Thanks

It seems you are on flutter master channel. Does it work on stable?

@alextekartik
I am working on DEV channel. Issue exists on flutter doctor environment as shown above.. Please let me know if you need more details.

If you can't replicate this issue with this command then try "ip addr" command instead of "ls" command.

Are you on the latest version of process_run (0.11.2 / 0.12.1) and if not can you try a pub upgrade. A log of the crash would be helpful as I cannot reproduce (although I'm suspecting an issue similar to #32 which should be fixed). Also, as I asked before, does it work on flutter stable?

I am using process_run : 0.11.2 and not able to upgrade to 0..12.1 because of another issue : #40

Can you provide a log of the crash? 0.11.2 (pre-nnbd) should be fine.

@alextekartik
It directly hangs-up application there is no log found for this. I will keep trying to get log using logger and will share if found anything.

Can you try to wrap with a try/catch and print the error and stacktrace?

@alextekartik
It's already wrapped in TRY/CATCH but there is no issue detail I found. It hang app directly or crash no log or details found.

Ok, let's try the good old printf debugging (I'm assuming you're on Linux), can you try this in your main() to see what the logs give and whether it hangs (sorry if you already tried, I don't have much idea on what to try next):

  print('Before');
  try {
    var shell = Shell();
    var res = await shell.run('ls');
    print(res.outLines);
  } catch (e) {
    print('error: $e');
  }
  print('After');

Please try on the beta or stable channel.