diem/diem · error
Can't resolve module at {:?}
Error message
Can't resolve module at {:?} What it means
`move generate struct-layouts` first resolves the package/module path to a compiled module via the Move build/resolve session. When the module cannot be resolved at the given path, the command bails with this message. It means the path doesn't point at a resolvable Move package/module that the build system can compile.
Source
Thrown at language/tools/move-cli/src/sandbox/commands/generate.rs:40
// Generate for one struct
let type_params = type_params_opt.as_ref().unwrap().to_vec(); // always Some if struct_opt is
let name = Identifier::new(struct_.as_str())?;
let struct_tag = StructTag {
address: *module_id.address(),
module: module_id.name().to_owned(),
name,
type_params,
};
let layout = StructLayoutBuilder::build_with_fields(&struct_tag, state)?;
// save to disk
state.save_layout_yaml(struct_tag, &layout)?;
println!("{}", layout);
} else {
unimplemented!("Generating layout for all structs in a module. Use the --module and --struct options")
}
Ok(())
} else {
bail!("Can't resolve module at {:?}", path)
}
}
View on GitHub (pinned to fc4714a8ea)
Solutions
- Run from (or pass --path to) the Move package root containing a valid Move.toml.
- Verify the package compiles first with `move build`; fix any compile errors reported.
- Confirm the module name passed via --module exists in the package sources.
- Check Move.toml dependencies resolve (run `move build` and inspect errors).
Example fix
// before $ move generate struct-layouts --path ./scripts --module 0x1::account --struct Account Can't resolve module at "./scripts" // after: point at the package root $ cd my_pkg && move generate struct-layouts --path . --module 0x1::account --struct Account
Defensive patterns
Strategy: validation
Validate before calling
// Verify path is a Move package root before generating layouts
if !path.join("Move.toml").exists() {
fatal("--path must point at a Move package containing Move.toml");
}
run("move build").expect("package must compile before layout generation"); Prevention
- Run generate commands from the package root
- Run `move build` first to catch resolution/compile errors
- Confirm module names with source files under sources/
When it happens
Trigger: Running `move generate struct-layouts` with a --path that is not a Move package root, has no Move.toml, contains compile errors, or names a module that doesn't exist in the package.
Common situations: Running the command from the wrong working directory; missing or malformed Move.toml; typo in the module path; package fails to compile so no resolved module is produced.
Related errors
- config must be a FullNode config
- Validator config must be a Validator config
- The following files were marked as both targets and dependen
- Invalid named address assignment. Must be of the form <addre
- Invalid command. Got error {} Lines {} - {}. {}
AI-assisted analysis of diem/diem@fc4714a8ea (2026-09-04).
Data as JSON: /api/errors/2a116d3e8a0e549e.
Report an issue: GitHub.