sinelaw/fresh · warning · io::Error (Unsupported)
Memory detection not implemented for this platform
Error message
Memory detection not implemented for this platform
What it means
total_memory_mb() reports the machine's total RAM so the editor can enforce process memory limits. Only Linux detection is implemented; on any other target OS the cfg(not(target_os = "linux")) arm returns io::ErrorKind::Unsupported. This is an explicit not-yet-ported error, not a runtime fault.
Solutions
- Skip or degrade process memory limiting when total_memory_mb() returns Unsupported
- Implement the platform arm using sysinfo/libc (host_statistics on macOS, GlobalMemoryStatusEx on Windows, sysconf on BSD)
- Use a cross-platform crate such as the `sysinfo` crate for detection
- Only call limit-setting code under #[cfg(target_os = "linux")]
Example fix
// before
let mem = total_memory_mb()?;
set_rlimit(RLIMIT_AS, mem)?;
// after
match total_memory_mb() {
Ok(mem) => set_rlimit(RLIMIT_AS, mem)?,
Err(e) if e.kind() == io::ErrorKind::Unsupported => log::info!("memory limits unavailable on this platform"),
Err(e) => return Err(e),
} Defensive patterns
Strategy: fallback
Validate before calling
#[cfg(not(target_os = "linux"))] let can_detect_memory = false; #[cfg(target_os = "linux")] let can_detect_memory = true;
Try / catch
match total_memory_mb() { Ok(mb) => apply_limit(mb), Err(e) if e.kind() == io::ErrorKind::Unsupported => log::info!("limits unsupported here"), Err(e) => return Err(e.into()), } Prevention
- Gate platform-specific limit setup behind cfg attributes
- Prefer std::thread::available_parallelism()/sysinfo crate over hand-rolled per-OS code
- Add cross-platform CI to catch unported code paths early
When it happens
Trigger: Calling process_limits::total_memory_mb() (public) on macOS, Windows, BSD, or any non-Linux target. Also affects anything downstream that depends on memory limits being initialized on those platforms.
Common situations: Building/running the editor on macOS or Windows with process limits enabled; cross-platform test suites calling limit setup unconditionally.
Understand the failure class
Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.
Related errors
- CPU detection not implemented for this platform
- TypeScript plugin thread creation failed
- this build was compiled without self-update support…
- Line indexing not available for this document
- Invalid range: start offset
AI-assisted analysis of sinelaw/fresh@67894ca546 (2026-09-13).
Data as JSON: /api/errors/225ad7a080115c8e.
Report an issue: GitHub.
Appendix: source
Thrown at crates/fresh-editor-core/src/process_limits.rs:318
fn get_uid() -> u32 {
unsafe { libc::getuid() }
}
/// System resource information utilities
pub struct SystemResources;
impl SystemResources {
/// Get total system memory in megabytes
pub fn total_memory_mb() -> io::Result<u64> {
#[cfg(target_os = "linux")]
{
Self::linux_total_memory_mb()
}
#[cfg(not(target_os = "linux"))]
{
// TODO: Implement for other platforms
Err(io::Error::new(
io::ErrorKind::Unsupported,
"Memory detection not implemented for this platform",
))
}
}
#[cfg(target_os = "linux")]
fn linux_total_memory_mb() -> io::Result<u64> {
// Read from /proc/meminfo
let meminfo = std::fs::read_to_string("/proc/meminfo")?;
for line in meminfo.lines() {
if line.starts_with("MemTotal:") {
// Format: "MemTotal: 16384000 kB"
let parts: Vec<&str> = line.split_whitespace().collect();
if parts.len() >= 2 {
if let Ok(kb) = parts[1].parse::<u64>() {
return Ok(kb / 1024); // Convert KB to MBView on GitHub (pinned to 67894ca546)