gpt4 book ai didi

dart - Process.run() : No such file or directory

转载 作者:行者123 更新时间:2023-12-03 02:57:02 30 4
gpt4 key购买 nike

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

$ 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() 失败了 No such file or directory 错误:
$ 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 构建?

最佳答案

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

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

关于dart - Process.run() : No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52715609/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com