NotImplementedError
RubyERRORNotablePlatform

Feature not implemented on this platform

Quick Answer

Check platform compatibility and provide an alternative code path for unsupported environments.

What this means

Raised when a feature is not implemented on the current platform or Ruby version. Unlike AbstractMethod patterns, this is a platform-level signal, not a design pattern. Subclass of ScriptError.

Why it happens
  1. 1Calling a POSIX method (e.g., fork) on Windows where it is unavailable
  2. 2Using a C extension feature not compiled for the current platform

Fix

Platform guard

Platform guard
if RUBY_PLATFORM.include?('linux')
  pid = fork { exec('worker') }
else
  puts 'fork not available on this platform'
end

Why this works

RUBY_PLATFORM identifies the OS so you can branch to a compatible implementation.

Code examples
Fork on Windowsruby
fork { puts 'child' }
# NotImplementedError: fork() function is unimplemented on this machine
Rescue itruby
begin
  fork { exec('job') }
rescue NotImplementedError
  system('job')   # fallback for Windows
end
Abstract method pattern (different use)ruby
def process
  raise NotImplementedError, "#{self.class}#process must be implemented"
end
Sources
Official documentation ↗

Ruby Core Documentation

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Ruby errors