{"record":{"id":"4c9a5e7152c43fc8","repo":"can1357/oh-my-pi","slug":"symlinks-not-supported-on-this-platform","errorCode":null,"errorMessage":"symlinks not supported on this platform","messagePattern":"symlinks not supported on this platform","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/ln.rs","lineNumber":609,"sourceCode":"fn make_symlink<P1: AsRef<Path>, P2: AsRef<Path>>(\n\thost: &Host,\n\tsrc: P1,\n\tdst: P2,\n) -> std::io::Result<()> {\n\tif host.resolve(src.as_ref()).is_dir() {\n\t\tsymlink_dir(src, dst)\n\t} else {\n\t\tsymlink_file(src, dst)\n\t}\n}\n\n#[cfg(target_os = \"wasi\")]\nfn make_symlink<P1: AsRef<Path>, P2: AsRef<Path>>(\n\t_host: &Host,\n\t_src: P1,\n\t_dst: P2,\n) -> std::io::Result<()> {\n\tErr(std::io::Error::new(\n\t\tstd::io::ErrorKind::Unsupported,\n\t\t\"symlinks not supported on this platform\",\n\t))\n}\n\n#[cfg(test)]\nmod tests {\n\tuse std::{fs, path::PathBuf};\n\n\tuse super::Ln;\n\tuse crate::host::run_util;\n\n\tfn run_in(cwd: PathBuf, args: &[&str]) -> (i32, String, String) {\n\t\tlet (code, capture) = run_util::<Ln>(args, \"\", cwd);\n\t\t(code, capture.out(), capture.err())\n\t}\n\n\tfn run_with_stdin(cwd: PathBuf, args: &[&str], stdin: &str) -> (i32, String, String) {","sourceCodeStart":591,"sourceCodeEnd":627,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/ln.rs#L591-L627","documentation":"On WASI targets, make_symlink is a stub that unconditionally returns io::ErrorKind::Unsupported with this message. The WASI host environment does not provide symlink creation, so any attempt to create a symbolic link through the ln builtin fails immediately.","triggerScenarios":"Calling ln with -s (or SYMLINK mode) while running compiled to wasm32-wasi, or any code path invoking make_symlink on that target.","commonSituations":"Cross-compiling the builtins to WASI (e.g. inside a wasm sandbox or plugin runtime) and running scripts that create symlinks.","solutions":["Avoid symlink creation when targeting WASI; use file copies instead","Detect the platform at runtime and branch to a copy-based fallback","If symlink support is required, run on a native target instead of WASI"],"exampleFix":"// before\nln(&host, &[\"-s\", \"target.txt\", \"link.txt\"])?;\n// after\n#[cfg(target_os = \"wasi\")]\nstd::fs::copy(\"target.txt\", \"link.txt\")?;\n#[cfg(not(target_os = \"wasi\"))]\nln(&host, &[\"-s\", \"target.txt\", \"link.txt\"])?;","handlingStrategy":"fallback","validationCode":"const SYMLINKS_SUPPORTED: bool = cfg!(not(target_os = \"wasi\"));\nfn can_symlink() -> bool { SYMLINKS_SUPPORTED }","typeGuard":null,"tryCatchPattern":"match ln(&host, &[\"-s\", src, dst]) {\n    Err(e) if e.to_string().contains(\"symlinks not supported\") => {\n        std::fs::copy(src, dst)?; // copy fallback on WASI\n    }\n    other => other?,\n}","preventionTips":["Gate symlink code behind cfg!(not(target_os = \"wasi\"))","Use file copies instead of symlinks in WASI/sandboxed targets","Test cross-compiled WASI builds before shipping symlink-dependent scripts"],"tags":["filesystem","symlink","wasi","platform-limitation","unsupported"],"backgroundTag":"symlinks-not-supported-on-platform","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}