can1357/oh-my-pi · error

symlinks not supported on this platform

Error message

symlinks not supported on this platform

What it means

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.

Source

Thrown at crates/pi-builtins/src/ln.rs:609

fn make_symlink<P1: AsRef<Path>, P2: AsRef<Path>>(
	host: &Host,
	src: P1,
	dst: P2,
) -> std::io::Result<()> {
	if host.resolve(src.as_ref()).is_dir() {
		symlink_dir(src, dst)
	} else {
		symlink_file(src, dst)
	}
}

#[cfg(target_os = "wasi")]
fn make_symlink<P1: AsRef<Path>, P2: AsRef<Path>>(
	_host: &Host,
	_src: P1,
	_dst: P2,
) -> std::io::Result<()> {
	Err(std::io::Error::new(
		std::io::ErrorKind::Unsupported,
		"symlinks not supported on this platform",
	))
}

#[cfg(test)]
mod tests {
	use std::{fs, path::PathBuf};

	use super::Ln;
	use crate::host::run_util;

	fn run_in(cwd: PathBuf, args: &[&str]) -> (i32, String, String) {
		let (code, capture) = run_util::<Ln>(args, "", cwd);
		(code, capture.out(), capture.err())
	}

	fn run_with_stdin(cwd: PathBuf, args: &[&str], stdin: &str) -> (i32, String, String) {

View on GitHub (pinned to 9690622007)

Solutions

  1. Avoid symlink creation when targeting WASI; use file copies instead
  2. Detect the platform at runtime and branch to a copy-based fallback
  3. If symlink support is required, run on a native target instead of WASI

Example fix

// before
ln(&host, &["-s", "target.txt", "link.txt"])?;
// after
#[cfg(target_os = "wasi")]
std::fs::copy("target.txt", "link.txt")?;
#[cfg(not(target_os = "wasi"))]
ln(&host, &["-s", "target.txt", "link.txt"])?;
Defensive patterns

Strategy: fallback

Validate before calling

const SYMLINKS_SUPPORTED: bool = cfg!(not(target_os = "wasi"));
fn can_symlink() -> bool { SYMLINKS_SUPPORTED }

Try / catch

match ln(&host, &["-s", src, dst]) {
    Err(e) if e.to_string().contains("symlinks not supported") => {
        std::fs::copy(src, dst)?; // copy fallback on WASI
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling ln with -s (or SYMLINK mode) while running compiled to wasm32-wasi, or any code path invoking make_symlink on that target.

Common situations: Cross-compiling the builtins to WASI (e.g. inside a wasm sandbox or plugin runtime) and running scripts that create symlinks.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/4c9a5e7152c43fc8. Report an issue: GitHub.