Bug 290975 - databases/mongosh: Fails to build
Summary: databases/mongosh: Fails to build
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Dan Langille
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-11-12 15:17 UTC by Einar Bjarni Halldórsson
Modified: 2026-01-19 14:20 UTC (History)
5 users (show)

See Also:
fabien.amelinck+freebsd: maintainer-feedback+
fabien.amelinck+freebsd: merge-quarterly?


Attachments
Poudriere build log (143.88 KB, text/plain)
2025-11-12 15:17 UTC, Einar Bjarni Halldórsson
no flags Details
patch that fixes build with node24 (2.39 KB, patch)
2025-11-25 10:49 UTC, Fabien Amelinck
fabien.amelinck+freebsd: maintainer-approval+
Details | Diff
git_diff_v1 (1.16 KB, patch)
2025-12-16 09:09 UTC, Fabien Amelinck
fabien.amelinck+freebsd: maintainer-approval+
Details | Diff
git_diff_v2 (2.77 KB, patch)
2025-12-31 09:33 UTC, Fabien Amelinck
fabien.amelinck+freebsd: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Einar Bjarni Halldórsson 2025-11-12 15:17:14 UTC
Created attachment 265362 [details]
Poudriere build log

mongosh started failing to build at 2025-11-12_03h05m01s

Both 2.5.5_2 and 2.5.5_3 fail in the same way:

Applying patch from /wrkdirs/usr/ports/databases/mongosh/work/mongosh-2.5.5/scripts/nodejs-patches/001-configure-bz2.patch...
Applying patch from /wrkdirs/usr/ports/databases/mongosh/work/mongosh-2.5.5/scripts/nodejs-patches/002-workaround-node-bug-52229...
Applying patch from /wrkdirs/usr/ports/databases/mongosh/work/mongosh-2.5.5/scripts/nodejs-patches/003-no-sys-random-on-older-glibc-node-52223.patch...
Applying patch from /wrkdirs/usr/ports/databases/mongosh/work/mongosh-2.5.5/scripts/nodejs-patches/004-build-fix-arm64-cross-compilation.patch...
Applying patch from /wrkdirs/usr/ports/databases/mongosh/work/mongosh-2.5.5/scripts/nodejs-patches/010-src-cares_wrap.h...
Applying patch from /wrkdirs/usr/ports/databases/mongosh/work/mongosh-2.5.5/scripts/nodejs-patches/011-deps-v8-src-base-small-vector.h...
error: patch failed: deps/v8/src/base/small-vector.h:22
error: deps/v8/src/base/small-vector.h: patch does not apply
  ✖  Failed: applying patch failed with code 1
/wrkdirs/usr/ports/databases/mongosh/work/mongosh-2.5.5/packages/build/src/compile/signable-compiler.ts:67
      throw new Error(`applying patch failed with code ${code}`);
            ^
Error: applying patch failed with code 1
    at Object.preCompileHook (/wrkdirs/usr/ports/databases/mongosh/work/mongosh-2.5.5/packages/build/src/compile/signable-compiler.ts:67:13)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async compileJSFileAsBinaryImpl (/wrkdirs/usr/ports/databases/mongosh/work/mongosh-2.5.5/node_modules/boxednode/src/index.ts:387:5)
    at async compileJSFileAsBinary (/wrkdirs/usr/ports/databases/mongosh/work/mongosh-2.5.5/node_modules/boxednode/src/index.ts:509:5)
    at async SignableCompiler.compile (/wrkdirs/usr/ports/databases/mongosh/work/mongosh-2.5.5/packages/build/src/compile/signable-compiler.ts:172:5)
    at async runCompile (/wrkdirs/usr/ports/databases/mongosh/work/mongosh-2.5.5/packages/build/src/compile/run-compile.ts:21:3)
    at async release (/wrkdirs/usr/ports/databases/mongosh/work/mongosh-2.5.5/packages/build/src/release.ts:86:5)
    at async /wrkdirs/usr/ports/databases/mongosh/work/mongosh-2.5.5/packages/build/src/index.ts:115:9
npm error Lifecycle script `evergreen-release` failed with error:
npm error code 1
npm error path /wrkdirs/usr/ports/databases/mongosh/work/mongosh-2.5.5/packages/build
npm error workspace @mongosh/build@3.7.0
npm error location /wrkdirs/usr/ports/databases/mongosh/work/mongosh-2.5.5/packages/build
npm error command failed
npm error command sh -c ts-node -r ../../scripts/import-expansions.js src/index.ts compile
*** Error code 1

Stop.
make: stopped in /usr/ports/databases/mongosh
Comment 1 Fabien Amelinck 2025-11-19 09:10:57 UTC
This is due to the newly set node24 as lts. My mongosh port follow node's lts so I have to update some patches.
Comment 2 jonathan 2025-11-24 02:35:57 UTC
I removed that patch file locally and eventually wound up dying with this at the end of the output


→  Running ./configure --disable-shared-readonly-heap --prefix=/usr/local --shared-brotli --shared-cares --shared-libuv --shared-nghttp2 --shared-nghttp3 --shared-ngtcp2 --shared-simdjson --shared-zlib --shared-zstd --shared-openssl --openssl-use-def-ca-store --with-intl=system-icu --without-npm --link-module ./lib-boxednode/mongosh.js ...
Node.js configure: Found Python 3.11.12...
gyp: --disable-shared-readonly-heap not found (cwd: /usr/ports/databases/mongosh/work/boxednode/mongosh/node-v24.11.0) while trying to load --disable-shared-readonly-heap
Error running GYP
  ✖  Failed: Command failed: ./configure --disable-shared-readonly-heap --prefix=/usr/local --shared-brotli --shared-cares --shared-libuv --shared-nghttp2 --shared-nghttp3 --shared-ngtcp2 --shared-simdjson --shared-zlib --shared-zstd --shared-openssl --openssl-use-def-ca-store --with-intl=system-icu --without-npm --link-module ./lib-boxednode/mongosh.js (code 1)
Error: Command failed: ./configure --disable-shared-readonly-heap --prefix=/usr/local --shared-brotli --shared-cares --shared-libuv --shared-nghttp2 --shared-nghttp3 --shared-ngtcp2 --shared-simdjson --shared-zlib --shared-zstd --shared-openssl --openssl-use-def-ca-store --with-intl=system-icu --without-npm --link-module ./lib-boxednode/mongosh.js (code 1)
    at Object.spawnBuildCommand (/usr/ports/databases/mongosh/work/mongosh-2.5.5/node_modules/boxednode/src/helpers.ts:47:11)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async compileNode (/usr/ports/databases/mongosh/work/mongosh-2.5.5/node_modules/boxednode/src/index.ts:212:5)
    at async writeMainFileAndCompile (/usr/ports/databases/mongosh/work/mongosh-2.5.5/node_modules/boxednode/src/index.ts:441:12)
    at async compileJSFileAsBinaryImpl (/usr/ports/databases/mongosh/work/mongosh-2.5.5/node_modules/boxednode/src/index.ts:454:18)
    at async compileJSFileAsBinary (/usr/ports/databases/mongosh/work/mongosh-2.5.5/node_modules/boxednode/src/index.ts:509:5)
    at async SignableCompiler.compile (/usr/ports/databases/mongosh/work/mongosh-2.5.5/packages/build/src/compile/signable-compiler.ts:172:5)
    at async runCompile (/usr/ports/databases/mongosh/work/mongosh-2.5.5/packages/build/src/compile/run-compile.ts:21:3)
    at async release (/usr/ports/databases/mongosh/work/mongosh-2.5.5/packages/build/src/release.ts:86:5)
    at async /usr/ports/databases/mongosh/work/mongosh-2.5.5/packages/build/src/index.ts:115:9
npm error Lifecycle script `evergreen-release` failed with error:
npm error code 1
npm error path /usr/ports/databases/mongosh/work/mongosh-2.5.5/packages/build
npm error workspace @mongosh/build@3.7.0
npm error location /usr/ports/databases/mongosh/work/mongosh-2.5.5/packages/build
npm error command failed
npm error command sh -c ts-node -r ../../scripts/import-expansions.js src/index.ts compile
*** Error code 1
Comment 3 Fabien Amelinck 2025-11-25 10:49:31 UTC
Created attachment 265639 [details]
patch that fixes build with node24

I did not update mongosh to the latest version for now. This is just to fix the build of mongosh 2.5.5.
Comment 4 jonathan 2025-11-26 00:39:25 UTC
mongosh built with that patch but I get ">mongosh 
Assertion failed: (EmbedderSnapshotData::CanUseCustomSnapshotPerIsolate()), function RunNodeInstance, file ../src/node_main.cc, line 251." when I try to run it.
Comment 5 Fabien Amelinck 2025-12-02 08:48:36 UTC
I opened an issue upstream:
https://jira.mongodb.org/projects/MONGOSH/issues/MONGOSH-3046

I guess I'll have to set node22 as default build version for now.
Comment 6 Fabien Amelinck 2025-12-16 09:09:45 UTC
Created attachment 266243 [details]
git_diff_v1

I will stick to node22 for now as node24 is not supported upstream to build mongosh.
Comment 7 Fabien Amelinck 2025-12-31 09:33:38 UTC
Created attachment 266678 [details]
git_diff_v2

I added some debug arguments during the build time.
I don't understand why I get this behaviour on 15 :

> > lerna run compile --scope @mongosh/cli-repl --include-dependencies
> 
> lerna notice cli v8.1.8
> memory allocation of 84 bytes failed
> lerna ERR! RuntimeError: unreachable
> lerna ERR!     at wasm://wasm/00b1b5a2:wasm-function[3313]:0x24558e
> lerna ERR!     at wasm://wasm/00b1b5a2:wasm-function[3235]:0x245345
> lerna ERR!     at wasm://wasm/00b1b5a2:wasm-function[3249]:0x2453bb
> lerna ERR!     at wasm://wasm/00b1b5a2:wasm-function[3123]:0x244df9
> lerna ERR!     at wasm://wasm/00b1b5a2:wasm-function[3136]:0x244ea3
> lerna ERR!     at wasm://wasm/00b1b5a2:wasm-function[3135]:0x244e98
> lerna ERR!     at wasm://wasm/00b1b5a2:wasm-function[3131]:0x244e66
> lerna ERR!     at wasm://wasm/00b1b5a2:wasm-function[2919]:0x243a87
> lerna ERR!     at wasm://wasm/00b1b5a2:wasm-function[1093]:0x1e408d
> lerna ERR! lerna unreachable
> *** Error code 1
> 
> Stop.
> make: stopped making "build" in /usr/ports/databases/mongosh
Comment 8 Eirik Oeverby 2026-01-04 22:58:34 UTC
Just stumbled upon this as well; is there a working fix on the way? I find myself in the middle of an upgrade and with no working CLI this is very difficult :-D

I found that `npm install mongosh` gives me a working version, even with node/npm 24..
Comment 9 Fabien Amelinck 2026-01-05 12:50:06 UTC
(In reply to Eirik Oeverby from comment #8)

The fix attached works fine on 13 et 14 but randomly fails on 15, I don't know why.

Of course you can install it with npm but the space taken by the project is significantly larger :(
Comment 10 Dan Langille freebsd_committer freebsd_triage 2026-01-13 22:02:15 UTC
This hit me today on FreeBSD 14.3 on head - a rough place to be right now.
Comment 11 Dan Langille freebsd_committer freebsd_triage 2026-01-13 22:22:06 UTC
(In reply to Fabien Amelinck from comment #5)

Choosing to use node22 is not an option.

The port contains: "USES= nodejs:lts,build"
Comment 12 Fabien Amelinck 2026-01-14 08:18:07 UTC
(In reply to Dan Langille from comment #11)

Yes I chose lts in the past to follow node's lts but mongosh does not support it currently so I froze the version to node22 in my attached patch.

You can set "nodejs:22,build" to test yourself.
Comment 13 Dan Langille freebsd_committer freebsd_triage 2026-01-14 19:26:04 UTC
This patch applies cleanly and builds here at $WORK.
Comment 14 commit-hook freebsd_committer freebsd_triage 2026-01-14 19:29:41 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=41be8a32ce0abd7aceb444172c787518a086cd22

commit 41be8a32ce0abd7aceb444172c787518a086cd22
Author:     Dan Langille <dvl@FreeBSD.org>
AuthorDate: 2026-01-14 19:27:42 +0000
Commit:     Dan Langille <dvl@FreeBSD.org>
CommitDate: 2026-01-14 19:27:42 +0000

    databases/mongosh: Fix build by using nodejs22

    This doesn't build with lts any more.

    PR:             290975

 databases/mongosh/Makefile                 | 6 +++---
 databases/mongosh/files/patch-package.json | 9 +++++++++
 2 files changed, 12 insertions(+), 3 deletions(-)
Comment 15 Dan Langille freebsd_committer freebsd_triage 2026-01-14 19:30:59 UTC
I think this should be backported to 2026Q1, otherwise, quarterly uses will be broken for another 3 months. I'll do that soon.
Comment 16 Fabien Amelinck 2026-01-19 09:14:33 UTC
Thanks a lot !

I added the flag to request quarterly merge.

See you.
Comment 17 commit-hook freebsd_committer freebsd_triage 2026-01-19 14:13:16 UTC
A commit in branch 2026Q1 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=bd3148af2d6a320e7ff5352915fd32d958bab741

commit bd3148af2d6a320e7ff5352915fd32d958bab741
Author:     Dan Langille <dvl@FreeBSD.org>
AuthorDate: 2026-01-14 19:27:42 +0000
Commit:     Dan Langille <dvl@FreeBSD.org>
CommitDate: 2026-01-19 14:11:10 +0000

    databases/mongosh: Fix build by using nodejs22

    This doesn't build with lts any more.

    PR:             290975
    (cherry picked from commit 41be8a32ce0abd7aceb444172c787518a086cd22)

 databases/mongosh/Makefile                 | 6 +++---
 databases/mongosh/files/patch-package.json | 9 +++++++++
 2 files changed, 12 insertions(+), 3 deletions(-)