{"record":{"id":"9df52b0c119431d7","repo":"ruby/rubygems","slug":"your-bundle-only-supports-platforms-platforms-m","errorCode":null,"errorMessage":"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.","messagePattern":"Your bundle only supports platforms #(.+?) but your local platform is #(.+?)\\. Add the current platform to the lockfile with\n`bundle lock --add-platform #(.+?)` and try again\\.","errorType":"exception","errorClass":"ProductionError","httpStatus":null,"severity":"error","filePath":"lib/bundler/definition.rb","lineNumber":527,"sourceCode":"        problem, expected, actual = diff\n\n        msg = case problem\n              when :engine\n                \"Your Ruby engine is #{actual}, but your Gemfile specified #{expected}\"\n              when :version\n                \"Your Ruby version is #{actual}, but your Gemfile specified #{expected}\"\n              when :engine_version\n                \"Your #{Bundler::RubyVersion.system.engine} version is #{actual}, but your Gemfile specified #{ruby_version.engine} #{expected}\"\n        end\n\n        raise RubyVersionMismatch, msg\n      end\n    end\n\n    def validate_platforms!\n      return if current_platform_locked? || @platforms.include?(Gem::Platform::RUBY)\n\n      raise ProductionError, \"Your bundle only supports platforms #{@platforms.map(&:to_s)} \" \\\n        \"but your local platform is #{Bundler.local_platform}. \" \\\n        \"Add the current platform to the lockfile with\\n`bundle lock --add-platform #{Bundler.local_platform}` and try again.\"\n    end\n\n    def normalize_platforms\n      resolve.normalize_platforms!(current_dependencies, platforms)\n\n      @resolve = SpecSet.new(resolve.for(current_dependencies, @platforms))\n    end\n\n    def add_platform(platform)\n      return if @platforms.include?(platform)\n\n      @new_platforms << platform\n      @platforms << platform\n    end\n\n    def remove_platform(platform)","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/ruby/rubygems/blob/86cbb817a38ce8477b181c17467a703ded3f2be8/lib/bundler/definition.rb#L509-L545","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\n$ bundle install\n# => Your bundle only supports platforms [\"x86_64-darwin-21\"] but your local platform is aarch64-linux\n\n# after\n$ bundle lock --add-platform aarch64-linux\n$ bundle install","handlingStrategy":"validation","validationCode":"local = Gem::Platform.local.to_s\nblock = Bundler.default_lockfile.read[/^PLATFORMS\\n((?:   .*\\n?)+)/].to_s\nlocked = block.lines.map(&:strip)\nunless locked.include?(local) || locked.include?(\"ruby\")\n  system(\"bundle\", \"lock\", \"--add-platform\", local) || abort(\"add platform #{local} to lockfile\")\nend","typeGuard":null,"tryCatchPattern":"begin\n  Bundler.definition.validate_runtime!\nrescue Bundler::ProductionError => e\n  raise unless e.message.include?(\"bundle lock --add-platform\")\n  platform = e.message[/--add-platform (\\S+)/, 1]\n  system(\"bundle\", \"lock\", \"--add-platform\", platform)\nend","preventionTips":["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"],"tags":["bundler","platform","lockfile","cross-platform","native-gems"],"backgroundTag":"unsupported-platform","analyzedSha":"86cbb817a38ce8477b181c17467a703ded3f2be8","analyzedAt":"2026-08-23T06:27:48.159Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}