FuelLabs/fuels-rs · error · syn::Error
Consider adding: Script(name="{}", project=...)
Error message
Consider adding: Script(name="{}", project=...) What it means
Compile-time validation error from setup_program_test, the script counterpart of the unknown-contract check: a LoadScript command references a script binding name that the Abigen command does not produce under ProgramType::Script. Each unknown name emits 'Script is unknown' on the literal plus this suggestion on the Abigen span.
Source
Thrown at packages/fuels-macros/src/setup_program_test/parsing/validations.rs:68
),
]
})
.validate_no_errors()
}
pub(crate) fn validate_all_scripts_are_known(
abigen_command: &AbigenCommand,
load_commands: &[LoadScriptCommand],
) -> Result<()> {
extract_scripts_to_load(load_commands)
.difference(&names_of_program_bindings(
abigen_command,
ProgramType::Script,
))
.flat_map(|unknown_contract| {
[
Error::new_spanned(unknown_contract, "Script is unknown"),
Error::new(
abigen_command.span,
format!(
"Consider adding: Script(name=\"{}\", project=...)",
unknown_contract.value()
),
),
]
})
.validate_no_errors()
}
pub(crate) fn validate_zero_or_one_wallet_command_present(
commands: &[InitializeWalletCommand],
) -> Result<()> {
if commands.len() > 1 {
commands
.iter()
.map(|command| Error::new(command.span, "Only one `Wallets` command allowed"))View on GitHub (pinned to d9a250a518)
Solutions
- Match the LoadScript name string exactly to a script binding in the Abigen command.
- If missing, add it: Abigen(scripts = [(name = "my_script", project = "../my_script")]).
- Confirm the binding sits under scripts=, not contracts=/predicates=.
Example fix
// before
setup_program_test!(
Abigen(scripts = [(name = "sum_script", project = "../sum")]),
LoadScript(name = "sum"),
)
// after
setup_program_test!(
Abigen(scripts = [(name = "sum_script", project = "../sum")]),
LoadScript(name = "sum_script"),
) Defensive patterns
Strategy: validation
Prevention
- Keep script bindings under scripts= in Abigen and reference the exact name in LoadScript.
- Grep the macro block for a binding name after any rename.
- Treat the 'Script is unknown' span as the authoritative location of the bad literal.
When it happens
Trigger: LoadScript(name = "my_script") where no script binding with that exact name exists in Abigen's scripts= list — typo, casing mismatch, the binding declared under contracts= instead, or the binding removed during cleanup.
Common situations: Renaming script bindings; mixing up which program type a binding was declared as; copying LoadScript lines between tests.
Related errors
- Unrecognized command. Expected one of: {msg}
- Only one `Abigen` command allowed
- Add an `Abigen(..)` command!
- Consider adding: Contract(name="{}", project=...)
- Only one `Wallets` command allowed
AI-assisted analysis of FuelLabs/fuels-rs@d9a250a518 (2026-08-16).
Data as JSON: /api/errors/ae88d4034302600b.
Report an issue: GitHub.