{"record":{"id":"e8edfbd97af318f8","repo":"FuelLabs/sway","slug":"could-not-get-homedir","errorCode":null,"errorMessage":"Could not get homedir","messagePattern":"Could not get homedir","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sway-core/src/sourcemap.rs","lineNumber":91,"sourceCode":null,"sourceCodeStart":null,"sourceCodeEnd":null,"githubUrl":"https://github.com/FuelLabs/sway/blob/47e5e902faa42baf652dd6a0c88cd23390c1a614/sway-core/src/sourcemap.rs#L91","documentation":"Source maps store dependency paths relative to ~/.forc so they resolve on any machine with the deps downloaded. SourceMapSpan::to_span rebuilds the absolute path by re-prefixing home_dir().join(\".forc\") when a span belongs to a dependency; this expect panics if home_dir() returns None (HOME unset / no user profile). Note the actual file is sway-core/src/source_map.rs:91 (sourcemap.rs in the report is a typo).","triggerScenarios":"Inverse source mapping (SourceMap::addr_to_span, used by forc addr2line / debug tooling) resolving a pc that lands inside a dependency source while HOME is unset — container/CI builds or services without a home directory.","commonSituations":"Running `forc addr2line` in CI containers without HOME; debugging a revert whose mapped location is in a dependency (e.g. sway-lib-std under ~/.forc) rather than user code.","solutions":["Set HOME before running: `export HOME=/root` (or `docker run -e HOME=...`).","Ensure dependencies are present under $HOME/.forc so the rebuilt prefix path is meaningful.","As a maintainer fix, fall back to the raw relative path instead of expecting: `home_dir().map(|h| h.join(\".forc\")).unwrap_or_else(|| PathBuf::from(\".forc\"))`."],"exampleFix":"// before (sway-core/src/source_map.rs:91)\nlet mut path = home_dir().expect(\"Could not get homedir\").join(\".forc\");\n// after\nlet mut path = home_dir().unwrap_or_default().join(\".forc\"); // or return Option and skip dep prefixing","handlingStrategy":"validation","validationCode":"# ensure a home directory exists before any debug/addr2line session\nif [ -z \"${HOME:-}\" ]; then export HOME=\"$PWD/.home\"; mkdir -p \"$HOME\"; fi\nforc addr2line -s out/debug/my_pkg-source_map.json 0x3a","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set HOME in containers/CI even when the build itself does not need it — debug tooling does.","Pre-download dependencies (`forc build`) so dependency paths under $HOME/.forc resolve.","When embedding source maps in other tools, avoid SourceMapSpan::to_span in HOME-less processes."],"tags":["rust","sway","sway-core","source-map","home-directory","panic","environment","addr2line"],"backgroundTag":null,"analyzedSha":"47e5e902faa42baf652dd6a0c88cd23390c1a614","analyzedAt":"2026-08-16T07:57:45.555Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}