Nokogiri: could not find a platform gem / libxml2 build error Ruby / Rails Origin: Application & API Last updated 5 Nov 2026

Bundler: Your bundle only supports platforms ["x86_64-linux"] but your local platform is arm64-darwin / Could not find gem 'nokogiri (1.16.0-arm64-darwin)'

The lockfile has no Nokogiri build for the current platform (precompiled "native" gems are per platform).

Exact message you may see Your bundle only supports platforms ["x86_64-linux"] but your local platform is arm64-darwinCould not find gem 'nokogiri (1.16.0-arm64-darwin)'Your bundle is locked to nokogiri (1.16.0) from rubygems repository, but that version can no longer be foundCould not find nokogiri-1.16.0-x86_64-linux in locally installed gemsbundle lock --add-platform
Seen on: Ruby Docker

Meaning

Add the platform: bundle lock --add-platform arm64-darwin x86_64-linux aarch64-linux, then bundle install. Alternatively force source builds (bundle config set force_ruby_platform true) which needs libxml2/libxslt headers. Common after switching Mac architecture or Docker on Apple Silicon.

Common causes

  • Gemfile.lock lacks the platform
  • Developing on arm64 Mac, deploying to x86_64 Linux
  • Docker multi-arch builds
  • Old Bundler (< 2.2) without platform-specific gems
  • force_ruby_platform set unexpectedly

⚡ Quick fix

  1. bundle lock --add-platform ruby x86_64-linux arm64-darwin
  2. bundle install
  3. Update Bundler: gem update --system && gem install bundler

Detailed fix by platform

Ruby

  1. bundle lock --add-platform x86_64-linux aarch64-linux arm64-darwin

How to diagnose

  1. Platforms — In lockfile?
  2. Arch — Local vs deploy?
  3. Bundler — Recent?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

ArgumentError: missing keyword / unknown keyword — Ruby: ArgumentError: missing keyword: :name / unknown keyword: :nmae (Ruby / Rails)ArgumentError: missin…Bundler could not find compatible versions for gem — Bundler: Bundler could not find compatible versions for gem "activesupport": In Gemfile: rails (= 7.1.0) depends on activesupport (= 7.1.0) (Ruby / Rails)Bundler could not fin…Bundler: Could not find gem in locally installed gems — Bundler: Could not find gem 'rails (~> 7.1)' in locally installed gems / Could not find rails-7.1.0 in any of the gem sources listed in your Gemfile (Ruby / Rails)Bundler: Could not fi…Failed to build gem native extension — Ruby: ERROR: Failed to build gem native extension. current directory: /gems/pg-1.5.4/ext/pg — An error occurred while installing pg (Ruby / Rails)Failed to build gem n…LoadError: cannot load such file — Ruby: LoadError: cannot load such file -- nokogiri (or: cannot load such file -- bundler/setup) (Ruby / Rails)LoadError: cannot loa…mach-o file, but is an incompatible architecture — macOS: dlopen: mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64') (macOS)mach-o file, but is a…Your Ruby version is X, but your Gemfile specified Y — Bundler: Your Ruby version is 3.1.2, but your Gemfile specified 3.3.0 (Ruby / Rails)Your Ruby version is …Nokogiri:…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.