FuelLabs/sway · error
the dependency `{}` could not be found in `{}`
Error message
the dependency `{}` could not be found in `{}` What it means
remove_deps_manifest_table removes entries from a section of Forc.toml ([dependencies] or [contract-dependencies]). The quoted branch fires when the whole section table is absent from the manifest (doc[section_name].as_table_mut() returns None); the same message is also bailed just below for a present section that lacks one of the named keys. Either way, the manifest does not contain what forc remove was asked to remove.
Source
Thrown at forc-pkg/src/manifest/dep_modifier.rs:358
}
Dependency::Detailed(details) => {
let mut inline = generate_table(details);
inline.insert("salt", Value::from(format!("0x{salt}")));
Item::Value(toml_edit::Value::InlineTable(inline))
}
};
table.insert(&dep_name, item);
}
};
Ok(())
}
pub fn remove_deps_manifest_table(self, doc: &mut DocumentMut, deps: &[&str]) -> Result<()> {
let section_name = self.to_string();
let section_table = doc[section_name.as_str()].as_table_mut().ok_or_else(|| {
anyhow!(
"the dependency `{}` could not be found in `{}`",
deps.join(", "),
section_name,
)
})?;
match self {
Section::Deps => {
for dep in deps {
if !section_table.contains_key(dep) {
bail!(
"the dependency `{}` could not be found in `{}`",
dep,
section_name
);
}
section_table.remove(dep);
}View on GitHub (pinned to 47e5e902fa)
Solutions
- Open Forc.toml and confirm the exact key exists under the expected section before removing.
- Use the flag matching the section: forc remove --contract-dependency <name> for contract deps, plain forc remove <name> for libraries.
- If the section genuinely does not exist, there is nothing to remove - delete the entry manually or skip.
- Check spelling and hyphenation of the dependency key as written in the manifest.
Example fix
# before: forc remove foo but Forc.toml has only
[contract-dependencies]
foo = { ... }
# after: target the right section
$ forc remove --contract-dependency foo Defensive patterns
Strategy: validation
Validate before calling
// Rust/shell, verify section and key exist before invoking forc remove: // shell: // grep -q '^\[dependencies\]$' Forc.toml && grep -q '^foo *= ' Forc.toml // Rust: parse the manifest with toml_edit and assert doc["dependencies"][name].is_some().
Try / catch
// anyhow Result - inspect and guide:
match remove_deps(...) {
Err(e) if e.to_string().contains("could not be found") =>
eprintln!("check the section ([dependencies] vs [contract-dependencies]) and key spelling"),
other => other.unwrap(),
} Prevention
- Read Forc.toml to confirm the exact dependency key before removing.
- Match the CLI flag to the section the dependency lives in.
- Keep dependency names consistent between Forc.toml and commands (hyphens, case).
When it happens
Trigger: Running forc remove <pkg> when Forc.toml has no [dependencies] table at all, or the dependency key exists only under a different section (e.g. contract-dependencies) or with a different spelling; the contract-deps variant hits the same guard for [contract-dependencies].
Common situations: Typo'd dependency names; wrong section (plain dep vs contract dep) because the matching flag was not passed; manifests where the section was already cleaned; running remove in the wrong project directory.
Related errors
- failed to read manifest at {:?}: {}
- dependency of {:?} named {:?} is invalid: {}
- failed to find package `{}` in {}
- failed to write toml file: {}
- missing dependency name
AI-assisted analysis of FuelLabs/sway@47e5e902fa (2026-08-16).
Data as JSON: /api/errors/56a1c358f1886ab9.
Report an issue: GitHub.