ruby/rubygems · error · ProductionError
Your bundle only supports platforms #{@platforms.map(&:to_s)
Error message
Your bundle only supports platforms #{@platforms.map(&:to_s)} but your local platform is #{Bundler.local_platform}. Add the current platform to the lockfile with
`bundle lock --add-platform #{Bundler.local_platform}` and try again. What it means
Definition#validate_platforms! (via validate_runtime!) requires that the running machine platform is recorded in the lockfile, unless the bundle is platform-agnostic (Gem::Platform::RUBY present in @platforms). When the local platform is absent it raises ProductionError listing the locked platforms versus Bundler.local_platform and prescribing `bundle lock --add-platform <local>` (lib/bundler/definition.rb:527). The guard ensures native-variant gems resolve for the machine actually running the bundle.
Source
Thrown at lib/bundler/definition.rb:527
problem, expected, actual = diff
msg = case problem
when :engine
"Your Ruby engine is #{actual}, but your Gemfile specified #{expected}"
when :version
"Your Ruby version is #{actual}, but your Gemfile specified #{expected}"
when :engine_version
"Your #{Bundler::RubyVersion.system.engine} version is #{actual}, but your Gemfile specified #{ruby_version.engine} #{expected}"
end
raise RubyVersionMismatch, msg
end
end
def validate_platforms!
return if current_platform_locked? || @platforms.include?(Gem::Platform::RUBY)
raise ProductionError, "Your bundle only supports platforms #{@platforms.map(&:to_s)} " \
"but your local platform is #{Bundler.local_platform}. " \
"Add the current platform to the lockfile with\n`bundle lock --add-platform #{Bundler.local_platform}` and try again."
end
def normalize_platforms
resolve.normalize_platforms!(current_dependencies, platforms)
@resolve = SpecSet.new(resolve.for(current_dependencies, @platforms))
end
def add_platform(platform)
return if @platforms.include?(platform)
@new_platforms << platform
@platforms << platform
end
def remove_platform(platform)View on GitHub (pinned to 86cbb817a3)
Solutions
- Run the exact command from the message, for example `bundle lock --add-platform x86_64-linux`, and commit the updated lockfile
- Pre-add every deployment target when locking: `bundle lock --add-platform aarch64-linux x86_64-linux`
- Compare the PLATFORMS block of Gemfile.lock with `ruby -e "puts Gem::Platform.local"` to see the missing entry
- For a single-OS team, deleting Gemfile.lock and re-running `bundle install` regenerates it for the local platform, at the cost of full re-resolution
Example fix
# before $ bundle install # => Your bundle only supports platforms ["x86_64-darwin-21"] but your local platform is aarch64-linux # after $ bundle lock --add-platform aarch64-linux $ bundle install
Defensive patterns
Strategy: validation
Validate before calling
local = Gem::Platform.local.to_s
block = Bundler.default_lockfile.read[/^PLATFORMS\n((?: .*\n?)+)/].to_s
locked = block.lines.map(&:strip)
unless locked.include?(local) || locked.include?("ruby")
system("bundle", "lock", "--add-platform", local) || abort("add platform #{local} to lockfile")
end Try / catch
begin
Bundler.definition.validate_runtime!
rescue Bundler::ProductionError => e
raise unless e.message.include?("bundle lock --add-platform")
platform = e.message[/--add-platform (\S+)/, 1]
system("bundle", "lock", "--add-platform", platform)
end Prevention
- Lock with all target platforms: bundle lock --add-platform x86_64-linux aarch64-linux
- Keep ruby in PLATFORMS as a fallback for pure-ruby gems
- Re-lock deliberately after OS or architecture upgrades
When it happens
Trigger: A Gemfile.lock generated on macOS (x86_64-darwin-21) used for bundle install on Linux CI; Apple Silicon developers joining a team whose lockfile only lists x86_64-darwin; macOS upgrades changing the darwin suffix so darwin-22 machines miss a darwin-21 lockfile; multi-arch Docker builds locking on one host architecture.
Common situations: Cross-OS teams (dev on mac, deploy on linux); CI adding a platform the lockfile never recorded; platform-suffix drift after OS upgrades; lockfiles with an incomplete PLATFORMS section.
Related errors
- This Bundle hasn't been installed yet. Run `bundle install`
- Your lockfile needs to be updated, but it can't be because f
- can't be updated because file system is read-only
- The Ruby version #{@locked_ruby_version} from #{@lockfile} c
- Frozen mode is set, but there's no lockfile
AI-assisted analysis of ruby/rubygems@86cbb817a3 (2026-08-23).
Data as JSON: /api/errors/9df52b0c119431d7.
Report an issue: GitHub.