MOD013: Shared module_prefix between root and dependency
Code: MOD013
Category: Module system
Since: v0.17.0
What this error means
Two packages in your project share the same module_prefix value, and one of them is the root project. This creates ambiguous import resolution: when the root project imports a module that only exists in the root, the compiler may silently route the import through the dependency instead, producing an opaque "not exported by package" error.
Example
# ailang.toml (root project)
[package]
name = "local/motoko_agent"
module_prefix = "src"
[dependencies]
"sunholo/motoko_core" = ">=0.1.0"
# .packages/motoko_core/ailang.toml
[package]
name = "sunholo/motoko_core"
module_prefix = "src" # ← same as root!
With this setup, import src/core/rpc in the root project can silently resolve as pkg/sunholo/motoko_core/core/rpc instead of the local file — even though rpc.ail is not exported by motoko_core.
How to fix
Option 1 — Remove the dependency from the root (most common fix)
If your root project IS the canonical source of the modules being imported, you don't need the dependency at the root level. Extension packages that need motoko_core can depend on it directly.
# ailang.toml (root project) — remove the dep
[dependencies]
# "sunholo/motoko_core" = ">=0.1.0" ← remove this
"sunholo/logging" = ">=0.4.0"
Option 2 — Change one side's module_prefix
Give either the root or the dep a distinct, non-overlapping prefix:
# In motoko_core's ailang.toml — use a longer unique segment
[package]
module_prefix = "motoko_core" # was "src"
Option 3 — Use explicit pkg/ imports in extension packages
Instead of relying on prefix resolution, extension packages can import the dep with its full pkg/ path:
-- Instead of: import src/core/tool_contract (...)
import pkg/sunholo/motoko_core/core/tool_contract (ToolContract)
Background
This error was introduced after the motoko_agent migration (v0.16.1) revealed that the silent misrouting caused confusing failures like module "sunholo/motoko_core/tool_contract" is not exported — with no diagnostic pointing to the shared-prefix ambiguity. MOD013 replaces that silent failure with an actionable message.