Skip to content

Commit de92eea

Browse files
committed
fix: mcpp auto-resolves LLVM from global xlings when sandbox payload missing
When xlings installs a toolchain into the mcpp sandbox, the payload may end up in xlings' own global data dir instead of the sandbox. Add fallback: if the expected xpkg path is missing, check ~/.xlings/data/xpkgs/ and copy from there. Remove CI workarounds: no more explicit `xlings install llvm` or pre-seed cp -r steps. mcpp now handles this like a real user would.
1 parent 32962c3 commit de92eea

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎src/pm/package_fetcher.cppm‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,28 @@ Fetcher::resolve_xpkg_path(std::string_view target,
627627
}
628628
}
629629
}
630+
if (!std::filesystem::exists(verdir)) {
631+
// xlings may have installed the package into its own global home
632+
// rather than the mcpp sandbox. Try to copy it from the global
633+
// xlings data directory.
634+
auto xlings_home_env = std::getenv("HOME");
635+
#if defined(_WIN32)
636+
if (!xlings_home_env) xlings_home_env = std::getenv("USERPROFILE");
637+
#endif
638+
if (xlings_home_env) {
639+
auto globalXpkgs = std::filesystem::path(xlings_home_env)
640+
/ ".xlings" / "data" / "xpkgs"
641+
/ verdir.parent_path().filename()
642+
/ verdir.filename();
643+
std::error_code ec;
644+
if (std::filesystem::exists(globalXpkgs, ec)) {
645+
std::filesystem::create_directories(verdir.parent_path(), ec);
646+
std::filesystem::copy(globalXpkgs, verdir,
647+
std::filesystem::copy_options::recursive
648+
| std::filesystem::copy_options::overwrite_existing, ec);
649+
}
650+
}
651+
}
630652
if (!std::filesystem::exists(verdir)) {
631653
return std::unexpected(CallError{
632654
std::format("xpkg payload missing: {}", verdir.string())});

0 commit comments

Comments
 (0)