Specify platform for jazzy gem install

Change-Id: I187a40c7e9e1cd41ca922fff459e69fbf34ad460
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/34040
Reviewed-by: Keyong Han <keyonghan@google.com>
Commit-Queue: Nehal Patel <nehalvpatel@google.com>
diff --git a/recipe_modules/flutter_deps/api.py b/recipe_modules/flutter_deps/api.py
index beaaaef..d94ac93 100644
--- a/recipe_modules/flutter_deps/api.py
+++ b/recipe_modules/flutter_deps/api.py
@@ -548,23 +548,22 @@
     with self.m.step.nest('Install jazzy'):
       self.m.file.ensure_directory('mkdir gems', gem_dir)
       with self.m.context(cwd=gem_dir):
-        # TODO: Un-pin sqlite3 version.
-        # https://github.com/flutter/flutter/issues/111226
+        # jazzy depends on sqlite3, which started serving precompiled gems with version 1.5.0.
+        # The instance of Ruby currently packaged with macOS installs precompiled gems incorrectly.
+        # Specifically, if a gem vends precompiled binaries, it installs the arm64 variant even on x86 machines.
+        # https://github.com/flutter/flutter/issues/111193#issuecomment-1248714857
+        # https://github.com/sparklemotion/nokogiri/issues/2165#issuecomment-754101252
+        # https://rubygems.org/gems/sqlite3/versions
 
-        # The next minor release of `sqlite3-ruby`, 1.5.0, caused build issues,
-        # so 1.4.4 is pinned. A proper fix should remove this step, as jazzy
-        # attempts to install sqlite3 on its own.
-        # https://github.com/flutter/flutter/issues/111193
-        self.m.step(
-            'install sqlite3', [
-                'gem', 'install', 'sqlite3:1.4.4',
-            '--install-dir', '.'
-            ]
-        )
+        platform_id = ('x86_64-darwin'
+          if self.m.platform.arch == 'intel'
+          else 'arm64-darwin')
+
         self.m.step(
             'install jazzy', [
                 'gem', 'install', 'jazzy:%s' % version,
-            '--install-dir', '.'
+                '--platform', platform_id,
+                '--install-dir', '.'
             ]
         )
       env['GEM_HOME'] = gem_dir
diff --git a/recipe_modules/flutter_deps/examples/full.expected/basic.json b/recipe_modules/flutter_deps/examples/full.expected/basic.json
index bfbf7b0..fb22f23 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/basic.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/basic.json
@@ -604,21 +604,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "name": "Install jazzy.install sqlite3",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.9.5",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipe_modules/flutter_deps/examples/full.expected/flutter_engine.json b/recipe_modules/flutter_deps/examples/full.expected/flutter_engine.json
index bec8467..942b3b2 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/flutter_engine.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/flutter_engine.json
@@ -688,21 +688,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "name": "Install jazzy.install sqlite3",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.9.5",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipe_modules/flutter_deps/examples/full.expected/goldTryjob.json b/recipe_modules/flutter_deps/examples/full.expected/goldTryjob.json
index bfbf7b0..fb22f23 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/goldTryjob.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/goldTryjob.json
@@ -604,21 +604,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "name": "Install jazzy.install sqlite3",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.9.5",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipe_modules/flutter_deps/examples/full.expected/linux.json b/recipe_modules/flutter_deps/examples/full.expected/linux.json
index bfbf7b0..fb22f23 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/linux.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/linux.json
@@ -604,21 +604,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "name": "Install jazzy.install sqlite3",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.9.5",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipe_modules/flutter_deps/examples/full.expected/local_engine_cas.json b/recipe_modules/flutter_deps/examples/full.expected/local_engine_cas.json
index 05f80f5..c662361 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/local_engine_cas.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/local_engine_cas.json
@@ -688,21 +688,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "name": "Install jazzy.install sqlite3",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.9.5",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipe_modules/flutter_deps/examples/full.expected/mac.json b/recipe_modules/flutter_deps/examples/full.expected/mac.json
index 989bf06..5085a8a 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/mac.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/mac.json
@@ -666,21 +666,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "name": "Install jazzy.install sqlite3",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.9.5",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipe_modules/flutter_deps/examples/full.expected/windows.json b/recipe_modules/flutter_deps/examples/full.expected/windows.json
index e1dc5c4..2a7c153 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/windows.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/windows.json
@@ -751,21 +751,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]\\gems",
-    "name": "Install jazzy.install sqlite3",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.9.5",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipe_modules/flutter_deps/examples/full.expected/with-arm64ruby.json b/recipe_modules/flutter_deps/examples/full.expected/with-arm64ruby.json
index be86c9e..b3386b8 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/with-arm64ruby.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/with-arm64ruby.json
@@ -604,21 +604,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "name": "Install jazzy.install sqlite3",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.9.5",
+      "--platform",
+      "arm64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipe_modules/flutter_deps/examples/full.expected/with-gems.json b/recipe_modules/flutter_deps/examples/full.expected/with-gems.json
index 596655f..ee17266 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/with-gems.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/with-gems.json
@@ -604,21 +604,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "name": "Install jazzy.install sqlite3",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.9.5",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipes/engine/engine.expected/mac.json b/recipes/engine/engine.expected/mac.json
index 9e6001c..da5f886 100644
--- a/recipes/engine/engine.expected/mac.json
+++ b/recipes/engine/engine.expected/mac.json
@@ -11230,50 +11230,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "env": {
-      "ANDROID_HOME": "[CACHE]/builder/src/third_party/android_tools/sdk",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_PREBUILT_DART_SDK": "True",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GOMA_DIR": "[CACHE]/goma/client"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
-      ]
-    },
-    "env_suffixes": {
-      "DEPOT_TOOLS_UPDATE": [
-        "0"
-      ],
-      "PATH": [
-        "RECIPE_REPO[depot_tools]"
-      ]
-    },
-    "luci_context": {
-      "realm": {
-        "name": "flutter:ci"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "install sqlite3"
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.8.4",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipes/engine/engine.expected/mac_font_subset.json b/recipes/engine/engine.expected/mac_font_subset.json
index 9e6001c..da5f886 100644
--- a/recipes/engine/engine.expected/mac_font_subset.json
+++ b/recipes/engine/engine.expected/mac_font_subset.json
@@ -11230,50 +11230,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "env": {
-      "ANDROID_HOME": "[CACHE]/builder/src/third_party/android_tools/sdk",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_PREBUILT_DART_SDK": "True",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GOMA_DIR": "[CACHE]/goma/client"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
-      ]
-    },
-    "env_suffixes": {
-      "DEPOT_TOOLS_UPDATE": [
-        "0"
-      ],
-      "PATH": [
-        "RECIPE_REPO[depot_tools]"
-      ]
-    },
-    "luci_context": {
-      "realm": {
-        "name": "flutter:ci"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "install sqlite3"
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.8.4",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipes/engine/engine.expected/mac_no_lto.json b/recipes/engine/engine.expected/mac_no_lto.json
index e26c612..e49203e 100644
--- a/recipes/engine/engine.expected/mac_no_lto.json
+++ b/recipes/engine/engine.expected/mac_no_lto.json
@@ -11238,50 +11238,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "env": {
-      "ANDROID_HOME": "[CACHE]/builder/src/third_party/android_tools/sdk",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_PREBUILT_DART_SDK": "True",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GOMA_DIR": "[CACHE]/goma/client"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
-      ]
-    },
-    "env_suffixes": {
-      "DEPOT_TOOLS_UPDATE": [
-        "0"
-      ],
-      "PATH": [
-        "RECIPE_REPO[depot_tools]"
-      ]
-    },
-    "luci_context": {
-      "realm": {
-        "name": "flutter:ci"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "install sqlite3"
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.8.4",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipes/engine/engine.expected/mac_no_lto_font_subset.json b/recipes/engine/engine.expected/mac_no_lto_font_subset.json
index e26c612..e49203e 100644
--- a/recipes/engine/engine.expected/mac_no_lto_font_subset.json
+++ b/recipes/engine/engine.expected/mac_no_lto_font_subset.json
@@ -11238,50 +11238,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "env": {
-      "ANDROID_HOME": "[CACHE]/builder/src/third_party/android_tools/sdk",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_PREBUILT_DART_SDK": "True",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GOMA_DIR": "[CACHE]/goma/client"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
-      ]
-    },
-    "env_suffixes": {
-      "DEPOT_TOOLS_UPDATE": [
-        "0"
-      ],
-      "PATH": [
-        "RECIPE_REPO[depot_tools]"
-      ]
-    },
-    "luci_context": {
-      "realm": {
-        "name": "flutter:ci"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "install sqlite3"
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.8.4",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipes/engine/engine.expected/mac_publish_cipd.json b/recipes/engine/engine.expected/mac_publish_cipd.json
index 9e6001c..da5f886 100644
--- a/recipes/engine/engine.expected/mac_publish_cipd.json
+++ b/recipes/engine/engine.expected/mac_publish_cipd.json
@@ -11230,50 +11230,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "env": {
-      "ANDROID_HOME": "[CACHE]/builder/src/third_party/android_tools/sdk",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_PREBUILT_DART_SDK": "True",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GOMA_DIR": "[CACHE]/goma/client"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
-      ]
-    },
-    "env_suffixes": {
-      "DEPOT_TOOLS_UPDATE": [
-        "0"
-      ],
-      "PATH": [
-        "RECIPE_REPO[depot_tools]"
-      ]
-    },
-    "luci_context": {
-      "realm": {
-        "name": "flutter:ci"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "install sqlite3"
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.8.4",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipes/engine/engine.expected/mac_publish_cipd_font_subset.json b/recipes/engine/engine.expected/mac_publish_cipd_font_subset.json
index 9e6001c..da5f886 100644
--- a/recipes/engine/engine.expected/mac_publish_cipd_font_subset.json
+++ b/recipes/engine/engine.expected/mac_publish_cipd_font_subset.json
@@ -11230,50 +11230,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "env": {
-      "ANDROID_HOME": "[CACHE]/builder/src/third_party/android_tools/sdk",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_PREBUILT_DART_SDK": "True",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GOMA_DIR": "[CACHE]/goma/client"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
-      ]
-    },
-    "env_suffixes": {
-      "DEPOT_TOOLS_UPDATE": [
-        "0"
-      ],
-      "PATH": [
-        "RECIPE_REPO[depot_tools]"
-      ]
-    },
-    "luci_context": {
-      "realm": {
-        "name": "flutter:ci"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "install sqlite3"
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.8.4",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipes/engine/engine.expected/mac_publish_cipd_no_lto.json b/recipes/engine/engine.expected/mac_publish_cipd_no_lto.json
index e26c612..e49203e 100644
--- a/recipes/engine/engine.expected/mac_publish_cipd_no_lto.json
+++ b/recipes/engine/engine.expected/mac_publish_cipd_no_lto.json
@@ -11238,50 +11238,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "env": {
-      "ANDROID_HOME": "[CACHE]/builder/src/third_party/android_tools/sdk",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_PREBUILT_DART_SDK": "True",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GOMA_DIR": "[CACHE]/goma/client"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
-      ]
-    },
-    "env_suffixes": {
-      "DEPOT_TOOLS_UPDATE": [
-        "0"
-      ],
-      "PATH": [
-        "RECIPE_REPO[depot_tools]"
-      ]
-    },
-    "luci_context": {
-      "realm": {
-        "name": "flutter:ci"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "install sqlite3"
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.8.4",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipes/engine/engine.expected/mac_publish_cipd_no_lto_font_subset.json b/recipes/engine/engine.expected/mac_publish_cipd_no_lto_font_subset.json
index e26c612..e49203e 100644
--- a/recipes/engine/engine.expected/mac_publish_cipd_no_lto_font_subset.json
+++ b/recipes/engine/engine.expected/mac_publish_cipd_no_lto_font_subset.json
@@ -11238,50 +11238,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "env": {
-      "ANDROID_HOME": "[CACHE]/builder/src/third_party/android_tools/sdk",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_PREBUILT_DART_SDK": "True",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GOMA_DIR": "[CACHE]/goma/client"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
-      ]
-    },
-    "env_suffixes": {
-      "DEPOT_TOOLS_UPDATE": [
-        "0"
-      ],
-      "PATH": [
-        "RECIPE_REPO[depot_tools]"
-      ]
-    },
-    "luci_context": {
-      "realm": {
-        "name": "flutter:ci"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "install sqlite3"
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.8.4",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipes/engine/engine.expected/mac_upload.json b/recipes/engine/engine.expected/mac_upload.json
index a506924..80a7645 100644
--- a/recipes/engine/engine.expected/mac_upload.json
+++ b/recipes/engine/engine.expected/mac_upload.json
@@ -12403,50 +12403,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "env": {
-      "ANDROID_HOME": "[CACHE]/builder/src/third_party/android_tools/sdk",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_PREBUILT_DART_SDK": "True",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GOMA_DIR": "[CACHE]/goma/client"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
-      ]
-    },
-    "env_suffixes": {
-      "DEPOT_TOOLS_UPDATE": [
-        "0"
-      ],
-      "PATH": [
-        "RECIPE_REPO[depot_tools]"
-      ]
-    },
-    "luci_context": {
-      "realm": {
-        "name": "flutter:ci"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "install sqlite3"
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.8.4",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipes/engine/engine.expected/mac_upload_font_subset.json b/recipes/engine/engine.expected/mac_upload_font_subset.json
index 0339b69..a3267e1 100644
--- a/recipes/engine/engine.expected/mac_upload_font_subset.json
+++ b/recipes/engine/engine.expected/mac_upload_font_subset.json
@@ -12505,50 +12505,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "env": {
-      "ANDROID_HOME": "[CACHE]/builder/src/third_party/android_tools/sdk",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_PREBUILT_DART_SDK": "True",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GOMA_DIR": "[CACHE]/goma/client"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
-      ]
-    },
-    "env_suffixes": {
-      "DEPOT_TOOLS_UPDATE": [
-        "0"
-      ],
-      "PATH": [
-        "RECIPE_REPO[depot_tools]"
-      ]
-    },
-    "luci_context": {
-      "realm": {
-        "name": "flutter:ci"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "install sqlite3"
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.8.4",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipes/engine/engine.expected/mac_upload_no_lto.json b/recipes/engine/engine.expected/mac_upload_no_lto.json
index b660882..954a67d 100644
--- a/recipes/engine/engine.expected/mac_upload_no_lto.json
+++ b/recipes/engine/engine.expected/mac_upload_no_lto.json
@@ -12411,50 +12411,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "env": {
-      "ANDROID_HOME": "[CACHE]/builder/src/third_party/android_tools/sdk",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_PREBUILT_DART_SDK": "True",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GOMA_DIR": "[CACHE]/goma/client"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
-      ]
-    },
-    "env_suffixes": {
-      "DEPOT_TOOLS_UPDATE": [
-        "0"
-      ],
-      "PATH": [
-        "RECIPE_REPO[depot_tools]"
-      ]
-    },
-    "luci_context": {
-      "realm": {
-        "name": "flutter:ci"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "install sqlite3"
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.8.4",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipes/engine/engine.expected/mac_upload_no_lto_font_subset.json b/recipes/engine/engine.expected/mac_upload_no_lto_font_subset.json
index 1b03be2..f4a33eb 100644
--- a/recipes/engine/engine.expected/mac_upload_no_lto_font_subset.json
+++ b/recipes/engine/engine.expected/mac_upload_no_lto_font_subset.json
@@ -12513,50 +12513,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "env": {
-      "ANDROID_HOME": "[CACHE]/builder/src/third_party/android_tools/sdk",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_PREBUILT_DART_SDK": "True",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GOMA_DIR": "[CACHE]/goma/client"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
-      ]
-    },
-    "env_suffixes": {
-      "DEPOT_TOOLS_UPDATE": [
-        "0"
-      ],
-      "PATH": [
-        "RECIPE_REPO[depot_tools]"
-      ]
-    },
-    "luci_context": {
-      "realm": {
-        "name": "flutter:ci"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "install sqlite3"
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.8.4",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipes/engine/engine.expected/mac_upload_publish_cipd.json b/recipes/engine/engine.expected/mac_upload_publish_cipd.json
index a506924..80a7645 100644
--- a/recipes/engine/engine.expected/mac_upload_publish_cipd.json
+++ b/recipes/engine/engine.expected/mac_upload_publish_cipd.json
@@ -12403,50 +12403,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "env": {
-      "ANDROID_HOME": "[CACHE]/builder/src/third_party/android_tools/sdk",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_PREBUILT_DART_SDK": "True",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GOMA_DIR": "[CACHE]/goma/client"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
-      ]
-    },
-    "env_suffixes": {
-      "DEPOT_TOOLS_UPDATE": [
-        "0"
-      ],
-      "PATH": [
-        "RECIPE_REPO[depot_tools]"
-      ]
-    },
-    "luci_context": {
-      "realm": {
-        "name": "flutter:ci"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "install sqlite3"
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.8.4",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipes/engine/engine.expected/mac_upload_publish_cipd_font_subset.json b/recipes/engine/engine.expected/mac_upload_publish_cipd_font_subset.json
index 0339b69..a3267e1 100644
--- a/recipes/engine/engine.expected/mac_upload_publish_cipd_font_subset.json
+++ b/recipes/engine/engine.expected/mac_upload_publish_cipd_font_subset.json
@@ -12505,50 +12505,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "env": {
-      "ANDROID_HOME": "[CACHE]/builder/src/third_party/android_tools/sdk",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_PREBUILT_DART_SDK": "True",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GOMA_DIR": "[CACHE]/goma/client"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
-      ]
-    },
-    "env_suffixes": {
-      "DEPOT_TOOLS_UPDATE": [
-        "0"
-      ],
-      "PATH": [
-        "RECIPE_REPO[depot_tools]"
-      ]
-    },
-    "luci_context": {
-      "realm": {
-        "name": "flutter:ci"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "install sqlite3"
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.8.4",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipes/engine/engine.expected/mac_upload_publish_cipd_no_lto.json b/recipes/engine/engine.expected/mac_upload_publish_cipd_no_lto.json
index b660882..954a67d 100644
--- a/recipes/engine/engine.expected/mac_upload_publish_cipd_no_lto.json
+++ b/recipes/engine/engine.expected/mac_upload_publish_cipd_no_lto.json
@@ -12411,50 +12411,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "env": {
-      "ANDROID_HOME": "[CACHE]/builder/src/third_party/android_tools/sdk",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_PREBUILT_DART_SDK": "True",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GOMA_DIR": "[CACHE]/goma/client"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
-      ]
-    },
-    "env_suffixes": {
-      "DEPOT_TOOLS_UPDATE": [
-        "0"
-      ],
-      "PATH": [
-        "RECIPE_REPO[depot_tools]"
-      ]
-    },
-    "luci_context": {
-      "realm": {
-        "name": "flutter:ci"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "install sqlite3"
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.8.4",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipes/engine/engine.expected/mac_upload_publish_cipd_no_lto_font_subset.json b/recipes/engine/engine.expected/mac_upload_publish_cipd_no_lto_font_subset.json
index 1b03be2..f4a33eb 100644
--- a/recipes/engine/engine.expected/mac_upload_publish_cipd_no_lto_font_subset.json
+++ b/recipes/engine/engine.expected/mac_upload_publish_cipd_no_lto_font_subset.json
@@ -12513,50 +12513,9 @@
     "cmd": [
       "gem",
       "install",
-      "sqlite3:1.4.4",
-      "--install-dir",
-      "."
-    ],
-    "cwd": "[START_DIR]/gems",
-    "env": {
-      "ANDROID_HOME": "[CACHE]/builder/src/third_party/android_tools/sdk",
-      "FLUTTER_LOGS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "FLUTTER_PREBUILT_DART_SDK": "True",
-      "FLUTTER_TEST_OUTPUTS_DIR": "[CLEANUP]/flutter_logs_dir",
-      "GOMA_DIR": "[CACHE]/goma/client"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
-      ]
-    },
-    "env_suffixes": {
-      "DEPOT_TOOLS_UPDATE": [
-        "0"
-      ],
-      "PATH": [
-        "RECIPE_REPO[depot_tools]"
-      ]
-    },
-    "luci_context": {
-      "realm": {
-        "name": "flutter:ci"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "install sqlite3"
-  },
-  {
-    "cmd": [
-      "gem",
-      "install",
       "jazzy:0.8.4",
+      "--platform",
+      "x86_64-darwin",
       "--install-dir",
       "."
     ],
diff --git a/recipes/engine/engine.py b/recipes/engine/engine.py
index 213c504..64b8785 100644
--- a/recipes/engine/engine.py
+++ b/recipes/engine/engine.py
@@ -1645,23 +1645,21 @@
   api.file.ensure_directory('mkdir gems', gem_dir)
 
   with api.context(cwd=gem_dir):
-    # TODO: Un-pin sqlite3 version.
-    # https://github.com/flutter/flutter/issues/111226
+    # jazzy depends on sqlite3, which started serving precompiled gems with version 1.5.0.
+    # The instance of Ruby currently packaged with macOS installs precompiled gems incorrectly.
+    # Specifically, if a gem vends precompiled binaries, it installs the arm64 variant even on x86 machines.
+    # https://github.com/flutter/flutter/issues/111193#issuecomment-1248714857
+    # https://github.com/sparklemotion/nokogiri/issues/2165#issuecomment-754101252
+    # https://rubygems.org/gems/sqlite3/versions
 
-    # The next minor release of `sqlite3-ruby`, 1.5.0, caused build issues,
-    # so 1.4.4 is pinned. A proper fix should remove this step, as jazzy
-    # attempts to install sqlite3 on its own.
-    # https://github.com/flutter/flutter/issues/111193
-    api.step(
-        'install sqlite3', [
-            'gem', 'install', 'sqlite3:1.4.4',
-            '--install-dir', '.'
-        ]
-    )
+    platform_id = ('x86_64-darwin'
+      if api.platform.arch == 'intel'
+      else 'arm64-darwin')
 
     api.step(
         'install jazzy', [
             'gem', 'install', 'jazzy:' + api.properties['jazzy_version'],
+            '--platform', platform_id,
             '--install-dir', '.'
         ]
     )