Process.run(): No such file or directory

Issue

I don’t understand, what am I doing wrong. I install (activate) grinder:

$ pub global activate grinder

Then I create a simple tool/grind.dart:

import "dart:io";
import "package:grinder/grinder.dart";

main(args) => grind(args);

@Task("Build")
build() {
  Process.run("webdev build", []);
}

But then Process.run() fails of No such file or directory error:

$ grind build
ProcessException: No such file or directory
  Command: webdev build 
#0      build (...project/tool/grind.dart:33:3)
<asynchronous suspension>
#1      _LocalLibraryMirror._invoke (dart:mirrors/runtime/libmirrors_impl.dart:1104:36)
#2      _LocalObjectMirror.invoke (dart:mirrors/runtime/libmirrors_impl.dart:230:25)
#3      TaskDiscovery.discoverDeclaration.<anon> (package:grinder/src/discover_tasks.dart:79:38)
#4      _rootRun (dart:async/zone.dart:1124:13)
#5      _CustomZone.run (dart:async/zone.dart:1021:19)
#6      _runZoned (dart:async/zone.dart:1516:10)
#7      runZoned (dart:async/zone.dart:1463:12)
#8      ZonedValue.withValue (package:grinder/src/utils.dart:112:12)
#9      GrinderTask.execute (package:grinder/src/grinder_task.dart:64:27)
#10     Grinder._invokeTask (package:grinder/src/grinder.dart:193:27)
#11     Grinder.start.<anon> (package:grinder/src/grinder.dart:168:16)
#12     Future.forEach.<anon> (dart:async/future.dart:486:26)
#13     Future.doWhile.<anon> (dart:async/future.dart:528:26)
#14     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#15     _RootZone.bindUnaryCallbackGuarded.<anon> (dart:async/zone.dart:1353:26)
#16     Future.doWhile (dart:async/future.dart:543:18)
#17     Future.forEach (dart:async/future.dart:484:12)
#18     Grinder.start (package:grinder/src/grinder.dart:167:21)
#19     runTasks (package:grinder/src/cli.dart:67:39)
<asynchronous suspension>
#20     grind (package:grinder/grinder.dart:46:12)
#21     main (...project/tool/grind.dart:9:15)

Even though webdev build does work correctly (is in path)?:

$ webdev build
Creating build script
...

What is the problem here? How could I fix this? Or is there a way to call webdev build programmatically right from Dart code?

Solution

The executable must not contain parameters.
Use instead:

Process.run("webdev", ["build"]);

Answered By – Günter Zöchbauer

Answer Checked By – Cary Denson (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *