Process.run():无此类文件或目录

时间:2018-10-09 07:34:31

标签: dart dart-io

我不明白,我在做什么错。我安装(激活)研磨机:

$ pub global activate grinder

然后,我创建一个简单的工具/grind.dart:

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

main(args) => grind(args);

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

但是然后Process.run()失败,没有这样的文件或目录错误:

$ 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)

即使webdev构建确实可以正常工作(在路径中)?:

$ webdev build
Creating build script
...

这是什么问题?我该如何解决?还是有一种方法可以直接从Dart代码中以编程方式调用webdev构建?

1 个答案:

答案 0 :(得分:1)

可执行文件不得包含参数。
改用:

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