# 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)'

**Code:** `Nokogiri: could not find a platform gem / libxml2 build error` · **Category:** Ruby / Rails · **Seen on:** Ruby, Docker

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/ruby/nokogiri-platform-gem-install-error)
