diff --git a/docs/guides/supported-systems.md b/docs/guides/supported-systems.md
index 8b41eeca4..88d9bba64 100644
--- a/docs/guides/supported-systems.md
+++ b/docs/guides/supported-systems.md
@@ -40,7 +40,9 @@ Should just work out of the box
Supported
On x64 systems, it should work right out of the box
-On Arm64 systems, the architecture needs to be overwritten with `MONGOMS_ARCH=x64`, only exception being (and based on) `ubuntu`
+Since Mongodb 6.0.0, they have `arm64` binaries
+Uses `arm64` binaries for all versions above or equal to `6.0.0`, for older versions falls back to using `x86_64` binaries (requires Rosetta)
+Usage of the `x86_64` binary can be forced with [`MONGOMS_ARCH=x64`](../api/config-options.md#arch) (or equal in `package.json`)
## Linux
diff --git a/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts b/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts
index 6e7947a0b..15bad1d35 100644
--- a/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts
+++ b/packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts
@@ -130,9 +130,19 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
name = `mongodb-macos`; // somehow these files are not listed in https://www.mongodb.org/dl/osx
}
+ // mongodb has native arm64
if (this.arch === 'aarch64') {
- log('getArchiveNameOsx: Arch is "aarch64", using x64 binary');
- this.arch = 'x86_64';
+ // force usage of "x86_64" binary for all versions below than 6.0.0
+ if (!isNullOrUndefined(version) && semver.lt(version, '6.0.0')) {
+ log('getArchiveNameOsx: Arch is "aarch64" and version is below 6.0.0, using x64 binary');
+ this.arch = 'x86_64';
+ } else {
+ log(
+ 'getArchiveNameOsx: Arch is "aarch64" and version is above or equal to 6.0.0, using arm64 binary'
+ );
+ // naming for macos is still "arm64" instead of "aarch64"
+ this.arch = 'arm64';
+ }
}
name += `-${this.arch}-${this.version}.tgz`;
diff --git a/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts b/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts
index da435b5d9..bcd06bb1f 100644
--- a/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts
+++ b/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts
@@ -71,7 +71,7 @@ describe('MongoBinaryDownloadUrl', () => {
);
});
- it('arm64 should use the x64 binary', async () => {
+ it('arm64 should use the x64 binary for versions below 6.0.0', async () => {
const du = new MongoBinaryDownloadUrl({
platform: 'darwin',
arch: 'arm64',
@@ -81,6 +81,17 @@ describe('MongoBinaryDownloadUrl', () => {
'https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.4.0.tgz'
);
});
+
+ it('arm64 should use the arm64 binary for versions above and equal to 6.0.0', async () => {
+ const du = new MongoBinaryDownloadUrl({
+ platform: 'darwin',
+ arch: 'arm64',
+ version: '6.0.0',
+ });
+ expect(await du.getDownloadUrl()).toBe(
+ 'https://fastdl.mongodb.org/osx/mongodb-macos-arm64-6.0.0.tgz'
+ );
+ });
});
describe('for linux', () => {