{"record":{"id":"22ede3204812273d","repo":"FuelLabs/sway","slug":"failed-to-find-package-in","errorCode":null,"errorMessage":"failed to find package `{}` in {}","messagePattern":"failed to find package `(.+?)` in (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"forc-pkg/src/source/git/mod.rs","lineNumber":219,"sourceCode":"        // probably fine for most cases as users should never be touching these\n        // directories, however we should add some code to validate this. E.g. can we\n        // recreate the git hash by hashing the directory or something along these lines\n        // using git?\n        // https://github.com/FuelLabs/sway/issues/7075\n        {\n            let _guard = lock.write()?;\n            if !repo_path.exists() {\n                println_action_green(\n                    \"Fetching\",\n                    &format!(\"{} {}\", ansiterm::Style::new().bold().paint(ctx.name), self),\n                );\n                fetch(ctx.fetch_id(), ctx.name(), self)?;\n            }\n        }\n        let path = {\n            let _guard = lock.read()?;\n            manifest::find_within(repo_path, ctx.name())\n                .ok_or_else(|| anyhow!(\"failed to find package `{}` in {}\", ctx.name(), self))?\n        };\n        PackageManifestFile::from_file(path)\n    }\n}\n\nimpl source::DepPath for Pinned {\n    fn dep_path(&self, name: &str) -> anyhow::Result<source::DependencyPath> {\n        let repo_path = commit_path(name, &self.source.repo, &self.commit_hash);\n        // Co-ordinate access to the git checkout directory using an advisory file lock.\n        let lock = forc_util::path_lock(&repo_path)?;\n        let _guard = lock.read()?;\n        let path = manifest::find_within(&repo_path, name)\n            .ok_or_else(|| anyhow!(\"failed to find package `{}` in {}\", name, self))?;\n        Ok(source::DependencyPath::ManifestPath(path))\n    }\n}\n\nimpl fmt::Display for Url {","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/FuelLabs/sway/blob/47e5e902faa42baf652dd6a0c88cd23390c1a614/forc-pkg/src/source/git/mod.rs#L201-L237","documentation":"After fetching a git dependency repo, forc searches it with manifest::find_within for a package whose Forc.toml declares the dependency's name. This error means the repo fetched fine but contains no package with that name - the key in [dependencies] must match the dependency's own [project].name, not the repo name.","triggerScenarios":"Declaring e.g. name = \"sway-lib-std\" while the repo's package is actually named \"std\"; the repo is a monorepo whose members have different names than the repository; the package was renamed upstream after you pinned it.","commonSituations":"Copy-pasting dependency snippets from docs where the key differs from the real package name; assuming the GitHub repo name is the package name.","solutions":["Open the fetched repo (under ~/.forc/git/checkouts) and read its Forc.toml [project] name; use exactly that string as your dependency key","If the repo hosts several packages, depend on the specific member's name","Delete Forc.lock and re-resolve after fixing the dependency key"],"exampleFix":"# before\n[dependencies]\nfoo = { git = \"https://github.com/org/foo\", tag = \"v1.0.0\" }\n# but the repo's package is named \"foo-core\"\n\n# after\n[dependencies]\nfoo-core = { git = \"https://github.com/org/foo\", tag = \"v1.0.0\" }","handlingStrategy":"validation","validationCode":"use forc_pkg::manifest;\n\n// after a manual clone/fetch, confirm the declared name exists before building\nlet found = manifest::find_within(&repo_checkout_dir, dep_name);\nif found.is_none() {\n    anyhow::bail!(\"dependency name `{dep_name}` not present in {repo_url}; check its Forc.toml [project].name\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always read the dependency repo's [project].name before adding the dependency key","Prefer official dependency snippets from the repo's own README","Delete Forc.lock after renaming dependency keys so names re-resolve"],"tags":["git","dependencies","manifest","forc","naming"],"backgroundTag":null,"analyzedSha":"47e5e902faa42baf652dd6a0c88cd23390c1a614","analyzedAt":"2026-08-16T07:57:45.555Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}