From 286b0044d5a9b7ee48af720136c7f8d866502581 Mon Sep 17 00:00:00 2001 From: "Aleksei (Faumaray) Selikhov" Date: Sun, 6 Dec 2026 11:44:35 +0300 Subject: [PATCH] fix(cli): resolve the project and build roots to absolute paths Actions run with their own working directory, so a relative --build-dir (as CI passes) left relative source paths in the graph and a dependency's snapshot sources could not be opened ('cc1plus: ... No such file or directory'). The build/test/install commands now normalize both roots up front. Verified locally: 'vbs install --build-dir build/repro-rel' failed before and installs successfully now. --- src/Main.cpp | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/src/Main.cpp b/src/Main.cpp index 2228f8d..4fe31d4 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -453,9 +453,26 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) { jobs = static_cast(parsed_jobs); } - const std::filesystem::path project_root{opts.project_arg}; + // Absolute roots: actions run with their own working directory, so relative + // paths baked into the graph (e.g. a dependency's snapshot sources) would not + // resolve. + std::error_code root_ec; + const std::filesystem::path project_root = + std::filesystem::absolute(opts.project_arg, root_ec).lexically_normal(); + if (root_ec) { + std::cerr << cmd_name << ": cannot resolve project directory '" + << opts.project_arg << "': " << root_ec.message() << '\n'; + return 1; + } const std::filesystem::path build_root = - opts.build_arg ? std::filesystem::path{*opts.build_arg} : (project_root / "build"); + opts.build_arg + ? std::filesystem::absolute(*opts.build_arg, root_ec).lexically_normal() + : (project_root / "build"); + if (root_ec) { + std::cerr << cmd_name << ": cannot resolve build directory '" << *opts.build_arg + << "': " << root_ec.message() << '\n'; + return 1; + } auto trusted_keys = combine_trusted_keys(opts.trusted_public_keys, opts.trusted_key_files, project_root); if (!trusted_keys) { @@ -2582,9 +2599,25 @@ int execute_install_command(const InstallCmdOptions &opts) { } } - const std::filesystem::path project_root{opts.project_arg}; + // Absolute roots: the self-hosted dependency build runs actions with their + // own working directory, so relative graph paths would not resolve. + std::error_code root_ec; + const std::filesystem::path project_root = + std::filesystem::absolute(opts.project_arg, root_ec).lexically_normal(); + if (root_ec) { + std::cerr << "vbs install: cannot resolve project directory '" << opts.project_arg + << "': " << root_ec.message() << '\n'; + return 1; + } const std::filesystem::path build_root = - opts.build_arg ? std::filesystem::path{*opts.build_arg} : (project_root / "build"); + opts.build_arg + ? std::filesystem::absolute(*opts.build_arg, root_ec).lexically_normal() + : (project_root / "build"); + if (root_ec) { + std::cerr << "vbs install: cannot resolve build directory '" << *opts.build_arg + << "': " << root_ec.message() << '\n'; + return 1; + } Install::InstallOptions iopts; iopts.prefix = *opts.prefix_arg;