docker - Github Actions + docker-compose 给出“没有这样的文件或目录”
问题描述
我正在用 Rust 为 Github Actions 编写 CI。docker-compose
由于某些原因,我想从 Rust 执行。在 中Command
,我在 docker-compose.yml 所在的文件夹中指定了当前工作目录。这是一些代码:
let docker_compose_file = current_dir.parent().unwrap().to_owned();
if docker_compose_file.join("docker-compose.yml").exists() {
println!(
"Found docker-compose file, full path: {:#?}",
docker_compose_file
);
// DEBUG CODE
let ls_result = Command::new("ls")
.arg(docker_compose_file.to_str().unwrap())
.output()
.unwrap()
.stdout;
let y = String::from_utf8(ls_result).unwrap();
println!("LS'ing gives: {:#?}", y);
} else {
panic!(
"Wrong file, current working dir: {:#?}",
docker_compose_file
);
}
let result = Command::new("docker-compose")
.current_dir(&docker_compose_file)
.args(&["up", "-d"])
.status()
.unwrap();
我在 Github Actions 中看到以下日志记录:
找到 docker-compose 文件,完整路径:“/Users/runner/work/something/something/server” LS'ing 给出:“Cargo.lock\nCargo.toml\napi\nbatch_jobs\nci_setup\ncommon\ndatabase\ndeployment.md \ndocker-compose.yml\nrustfmt.toml\nserver\ntarget\n" 线程 'main' 在'调用
Result::unwrap()
一个Err
值:Os { 代码:2,种类:NotFound,消息:“没有这样的文件或目录”}' , ci_setup/src/main.rs:137:14 注意:使用RUST_BACKTRACE=1
环境变量运行以显示回溯
我很困惑。ls
清楚地向我展示了 docker-compose.yml 文件存在。为什么我会收到 Rust 错误,说找不到文件或目录?
main.rs:137 指unwrap
的是代码示例底部的方法调用。
解决方案
推荐阅读
- html - HTML5 视频控件在页面加载时缩小
- android - Kotlin - 如何在映射和过滤时跳过异常条目
- android - 如何使用全选复选框选择包含复选框的列表视图的所有行
- r - 用上一行中的值替换特定值
- node.js - 收到错误 UnhandledPromiseRejectionWarning
- json - 有没有办法从 Couchdb 中获得更干净的 JSON?
- java - 匹配最接近的组,我真的无法形容
- android - 当应用程序处于前台时需要关闭点击通知 - android
- java - 如何在 Mockobject 的帮助下检查真实对象的空值?
- node.js - 在 Google App Engine 上部署后 Node Server 不会自动重启