{"record":{"id":"a311b9256c630d41","repo":"jdx/mise","slug":"cannot-relocate-replacement-for-does-not-fi","errorCode":null,"errorMessage":"cannot relocate {}: replacement for {} does not fit ({} > {} bytes)","messagePattern":"cannot relocate (.+?): replacement for (.+?) does not fit \\((.+?) > (.+?) bytes\\)","errorType":"exception","errorClass":"eyre::Report","httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/relocate.rs","lineNumber":176,"sourceCode":"            // keep); find the end at the next NUL\n            let str_end = content[start..]\n                .iter()\n                .position(|&b| b == 0)\n                .map(|p| start + p)\n                .unwrap_or(content.len());\n            // available slot: the string plus the run of NULs after it,\n            // minus one NUL that must remain as terminator\n            let slot_end = content[str_end..]\n                .iter()\n                .position(|&b| b != 0)\n                .map(|p| str_end + p)\n                .unwrap_or(content.len());\n            let old = content[start..str_end].to_vec();\n            let mut new = r.value.clone();\n            new.extend_from_slice(&old[r.placeholder.len()..]);\n            let slot = slot_end.saturating_sub(start);\n            if new.len() + 1 > slot {\n                bail!(\n                    \"cannot relocate {}: replacement for {} does not fit ({} > {} bytes)\",\n                    path.display(),\n                    String::from_utf8_lossy(r.placeholder),\n                    new.len() + 1,\n                    slot,\n                );\n            }\n            content[start..start + new.len()].copy_from_slice(&new);\n            for b in &mut content[start + new.len()..slot_end] {\n                *b = 0;\n            }\n            changed = true;\n            search_from = start + new.len();\n        }\n    }\n    Ok(changed)\n}\n","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/jdx/mise/blob/9dcfcaa0dc8747a2577d3270b69bb9d8313b2807/src/system/packages/brew/relocate.rs#L158-L194","documentation":"Bottle binaries embed fixed-size placeholder paths (the build machine's prefix, e.g. /usr/local or /opt/homebrew) that mise rewrites in place during relocation, because Mach-O/ELF offsets cannot grow. A replacement must fit into the original slot — the placeholder string plus its trailing run of NULs, minus one NUL kept as terminator. If the real prefix path is longer than the slot, in-place patching is impossible and relocation aborts with the byte counts.","triggerScenarios":"Relocating a file where the placeholder must be replaced by a much longer real path: the check new.len() + 1 > slot fails. Long usernames, deeply nested HOME/XDG dirs, or a custom mise data dir push the target path past the placeholder's slot size.","commonSituations":"Installing into /home/very-long-username/.local/share/mise/... where the path exceeds the placeholder by dozens of bytes; organizations redirecting HOME or XDG_DATA_HOME to long canonical paths in automount environments.","solutions":["Use the default (shorter) mise install prefix instead of a deeply nested custom one","Shorten the path: shallower HOME, shorter username, or a symlinked prefix such as /opt/mise pointing at the real location","Install that package with native Homebrew (its real paths match the placeholders) or via another backend"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# estimate before installing: placeholder slots are sized for short prefixes like /usr/local\nPREFIX=\"$(mise data-dir)/brew/...\"   # the real target path baked into binaries\necho \"target prefix length: ${#PREFIX} bytes (placeholders are ~10-15 bytes); keep it short or symlink /opt/mise -> $PREFIX\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use mise's default install locations — they are sized to fit bottle placeholders","Avoid deeply nested HOME/XDG paths or very long usernames on machines using brew packages","If a custom long path is unavoidable, symlink a short prefix like /opt/mise to it"],"tags":["brew","relocation","binary-patching","path-length"],"backgroundTag":"binary-relocation-path-too-long","analyzedSha":"9dcfcaa0dc8747a2577d3270b69bb9d8313b2807","analyzedAt":"2026-08-17T14:28:50.624Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}