{"record":{"id":"a5ef11ce124a1baf","repo":"FuelLabs/sway","slug":"cannot-get-parent-dir-of","errorCode":null,"errorMessage":"Cannot get parent dir of {:?}","messagePattern":"Cannot get parent dir of (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"forc-pkg/src/manifest/mod.rs","lineNumber":1032,"sourceCode":"        Ok(member_pkg_manifests)\n    }\n\n    /// Check if given path corresponds to any workspace member's path\n    pub fn is_member_path(&self, path: &Path) -> Result<bool> {\n        Ok(self.member_paths()?.any(|member_path| member_path == path))\n    }\n}\n\nimpl GenericManifestFile for WorkspaceManifestFile {\n    /// Given a path to a `Forc.toml`, read it and construct a `PackageManifest`\n    ///\n    /// This also `validate`s the manifest, returning an `Err` in the case that given members are\n    /// not present in the manifest dir.\n    fn from_file<P: AsRef<Path>>(path: P) -> Result<Self> {\n        let path = path.as_ref().canonicalize()?;\n        let parent = path\n            .parent()\n            .ok_or_else(|| anyhow!(\"Cannot get parent dir of {:?}\", path))?;\n        let manifest = WorkspaceManifest::from_file(&path)?;\n        manifest.validate(parent)?;\n        Ok(Self { manifest, path })\n    }\n\n    /// Read the manifest from the `Forc.toml` in the directory specified by the given `path` or\n    /// any of its parent directories.\n    ///\n    /// This is short for `PackageManifest::from_file`, but takes care of constructing the path to the\n    /// file.\n    fn from_dir<P: AsRef<Path>>(manifest_dir: P) -> Result<Self> {\n        let manifest_dir = manifest_dir.as_ref();\n        let dir = find_parent_manifest_dir_with_check(manifest_dir, |possible_manifest_dir| {\n            // Check if the found manifest file is a workspace manifest file or a standalone\n            // package manifest file.\n            let possible_path = possible_manifest_dir.join(constants::MANIFEST_FILE_NAME);\n            // We should not continue to search if the given manifest is a workspace manifest with\n            // some issues.","sourceCodeStart":1014,"sourceCodeEnd":1050,"githubUrl":"https://github.com/FuelLabs/sway/blob/47e5e902faa42baf652dd6a0c88cd23390c1a614/forc-pkg/src/manifest/mod.rs#L1014-L1050","documentation":"In WorkspaceManifestFile::from_file the Forc.toml path is canonicalized and then .parent() is taken; this error fires when parent() returns None, which for a canonicalized absolute path happens only when the file sits at the filesystem root ('/'). It is an internal sanity guard rather than a routine user error.","triggerScenarios":"WorkspaceManifestFile::from_file(path) where path canonicalizes to '/' - i.e. a Forc.toml literally placed at the filesystem root, or a path built by PathBuf::join where an absolute argument overwrote the base.","commonSituations":"Script builds '/' by joining an empty prefix with an absolute path; a Docker/CI step mounting a manifest at the root; otherwise essentially never seen.","solutions":["Print/inspect the path passed to from_file and make sure it points to a Forc.toml inside a real project directory.","Guard with path.parent().is_some() (after canonicalize) before calling the API.","Fix the path construction (use push instead of join with absolute components)."],"exampleFix":"// before\nlet ws = WorkspaceManifestFile::from_file(PathBuf::from(\"/\").join(\"Forc.toml\"))?;\n\n// after\nlet dir = std::env::current_dir()?.join(\"project\");\nassert!(dir.parent().is_some(), \"manifest must live inside a directory\");\nlet ws = WorkspaceManifestFile::from_file(dir.join(\"Forc.toml\"))?;","handlingStrategy":"type-guard","validationCode":"let canon = std::fs::canonicalize(&manifest_path)?;\nif canon.parent().map(|p| !p.as_os_str().is_empty()).unwrap_or(false) {\n    let ws = WorkspaceManifestFile::from_file(&manifest_path)?;\n}","typeGuard":"fn manifest_path_has_parent(path: &Path) -> bool {\n    path.canonicalize()\n        .ok()\n        .and_then(|p| p.parent().map(|x| !x.as_os_str().is_empty()))\n        .unwrap_or(false)\n}","tryCatchPattern":null,"preventionTips":["Pass absolute, non-root paths to manifest APIs.","Build paths with PathBuf::push so an absolute component cannot overwrite the base.","Never place Forc.toml at the filesystem root."],"tags":["filesystem","path","workspace","manifest"],"backgroundTag":null,"analyzedSha":"47e5e902faa42baf652dd6a0c88cd23390c1a614","analyzedAt":"2026-08-16T07:57:45.555Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}