Skip to content

fix: give an actionable error when moonbitlang/core is not bundled - #1750

Open
mvanhorn wants to merge 1 commit into
moonbitlang:mainfrom
mvanhorn:fix/1718-actionable-core-bundle-error
Open

mvanhorn wants to merge 1 commit into
moonbitlang:mainfrom
mvanhorn:fix/1718-actionable-core-bundle-error

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Jun 4, 2026

Copy link
Copy Markdown

Summary

moon build on a fresh install where ~/.moon/lib/core exists but was never bundled now fails with an actionable message that names the core directory and the exact remediation (moon -C <core_dir> bundle --target all), instead of the generic Cannot load the core file. A missing core directory gets its own message pointing at reinstalling the toolchain or $MOON_CORE_OVERRIDE.

Why this matters

#1718 hit this on Windows: the old error reads like a corruption/path bug and sends users down the wrong debugging path, while peter-jerry-ye's confirmed fix is just running the bundle command. The change is confined to the .context(...) on read_module_desc_file_in_dir in inject_std (crates/mooncake/src/resolver.rs); the underlying error stays in the source chain and the CannotInjectCore wrapper still prefixes the standard-library context.

Output after this change (exists-but-unbundled path):

Cannot inject the standard library `moonbitlang/core`: Cannot load the core file. The standard library at `/tmp/.../unbundled_core` does not appear to be bundled. Run `moon -C /tmp/.../unbundled_core bundle --target all` to bundle it

Metadata

  • Tests added/updated for bug fixes or new features - N/A for this diagnostics-only change; both failure paths verified by running the built moon binary against a minimal project with MOON_CORE_OVERRIDE pointing at an empty dir and a nonexistent dir (outputs above)
  • Compatible with Windows/Linux/macOS - message formatting only, no platform-specific APIs; cargo check -p mooncake and cargo fmt --check pass

@semanticdiff-com

semanticdiff-com Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  crates/mooncake/src/resolver.rs  22% smaller

@peter-jerry-ye

peter-jerry-ye commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Although I think the fix is fine, I don't think such situation should happen often enough to add a fix. Either it's because the user is trying to develop moonbitlang/core without reading CONTRIBUTING or there's a bug.

Such a fix would hide away such unexpected situation. I would need a stronger reason for this fix.

@peter-jerry-ye

Copy link
Copy Markdown
Contributor

Also I'm still waiting for the clarification for that issue because it claimed to be a "fresh installation"

@mvanhorn

mvanhorn commented Jun 6, 2026

Copy link
Copy Markdown
Author

That's fair - no pressure on this one. If the reporter's clarification shows it really was a fresh install hitting a missing core, this is ready; if it turns out to be a broken dev setup, happy to close it as not worth the surface area. I'll leave it to your call once they respond.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: Cannot inject the standard library moonbitlang/core after fresh install (v0.1.20260522)

2 participants