fix: resolve SemVer constraints through the index route, not the registry - #309
Merged
Conversation
…stry
`resolve_semver` / `try_merge_semver` took a `Fetcher&` and called
`read_xpkg_lua` on it, which only ever reads the shared registry under
`<XLINGS_HOME>/data`. Candidate selection, meanwhile, dispatches across all
three descriptor transports (local path index, project clone, registry).
The split meant a package served by a project `[indices]` entry resolved
fine as an exact version and failed the moment the same dependency carried
a constraint:
dependency 'acme.util' has SemVer constraint '^2.0' but the index entry
isn't cloned locally yet — run `mcpp index update` first
— advice that does nothing for a local path index, leaving no way forward.
Both functions now take `const IndexRoute&`, so the descriptor is reached
the same way everywhere. `mcpp new --template` passes a route with no
project indices, which is what it always meant: there is no project yet.
The not-found message drops the `mcpp index update` hint when a local path
index is what would have answered.
`prepare.cppm`'s `index_route` lambda moves above `resolveSemver` so the
resolver call can use it; nothing else about it changes.
Closes #308
Sunrisepeak
approved these changes
Jul 29, 2026
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
resolve_semver/try_merge_semver拿Fetcher&并直接read_xpkg_lua,只读共享 registry;而候选选择走的是mcpp.pm.index_route的三路分发(本地 path 索引 / 项目 clone / registry)。结果:项目
[indices]里的包,写死版本能解析,一旦带 SemVer 约束就挂 ——对本地 path 索引来说这条提示毫无作用,用户没有出路。
const IndexRoute&,描述符在所有路径上以同一种方式获取mcpp new --template传一个不含项目索引的 route —— 这正是它一直以来的语义(还没有工程)mcpp index update提示prepare.cppm的index_routelambda 上移到resolveSemver之前,自身无改动Closes #308
Test plan
mcpp build通过tests/e2e/169_semver_project_index.sh:本地 path 索引 +^2.0→ v2.1.0,同时锁住写死版本那条路径;载荷预置在工程 xlings data 目录,全程不联网origin/main(9959be5)构出的二进制上复现 issue 原文报错顺带发现(未在本 PR 处理)
lock 文件记的是约束而不是解析后的版本(
version = "^2.0"),共享 registry 依赖同样如此,属既有行为、非本次改动引入。锁不住版本对 lockfile 来说是个真问题,建议单开 issue。