laverdet / isolated-vm

Secure & isolated JS environments for nodejs
ISC License
2.18k stars 154 forks source link

`ModuleNotFoundError: No module named 'distutils'` on Vercel starting from version `4.8.0` #477

Closed baptisteArno closed 4 months ago

baptisteArno commented 5 months ago

Starting from version 4.8.0, isolated-vm can't be installed on Vercel.

The error is:

.../node_modules/isolated-vm install: gyp http GET https://nodejs.org/download/release/v20.12.2/SHASUMS256.txt
16:47:11.912 | .../node_modules/isolated-vm install: gyp http 200 https://nodejs.org/download/release/v20.12.2/SHASUMS256.txt
16:47:11.920 | .../node_modules/isolated-vm install: gyp info spawn /usr/local/bin/python3
16:47:11.923 | .../node_modules/isolated-vm install: gyp info spawn args [
16:47:11.923 | .../node_modules/isolated-vm install: gyp info spawn args   '/pnpm8/node_modules/pnpm/dist/node_modules/node-gyp/gyp/gyp_main.py',
16:47:11.924 | .../node_modules/isolated-vm install: gyp info spawn args   'binding.gyp',
16:47:11.924 | .../node_modules/isolated-vm install: gyp info spawn args   '-f',
16:47:11.924 | .../node_modules/isolated-vm install: gyp info spawn args   'make',
16:47:11.924 | .../node_modules/isolated-vm install: gyp info spawn args   '-I',
16:47:11.924 | .../node_modules/isolated-vm install: gyp info spawn args   '/vercel/path0/node_modules/.pnpm/isolated-vm@5.0.0/node_modules/isolated-vm/build/config.gypi',
16:47:11.924 | .../node_modules/isolated-vm install: gyp info spawn args   '-I',
16:47:11.924 | .../node_modules/isolated-vm install: gyp info spawn args   '/pnpm8/node_modules/pnpm/dist/node_modules/node-gyp/addon.gypi',
16:47:11.924 | .../node_modules/isolated-vm install: gyp info spawn args   '-I',
16:47:11.924 | .../node_modules/isolated-vm install: gyp info spawn args   '/vercel/.cache/node-gyp/20.12.2/include/node/common.gypi',
16:47:11.924 | .../node_modules/isolated-vm install: gyp info spawn args   '-Dlibrary=shared_library',
16:47:11.925 | .../node_modules/isolated-vm install: gyp info spawn args   '-Dvisibility=default',
16:47:11.925 | .../node_modules/isolated-vm install: gyp info spawn args   '-Dnode_root_dir=/vercel/.cache/node-gyp/20.12.2',
16:47:11.925 | .../node_modules/isolated-vm install: gyp info spawn args   '-Dnode_gyp_dir=/pnpm8/node_modules/pnpm/dist/node_modules/node-gyp',
16:47:11.925 | .../node_modules/isolated-vm install: gyp info spawn args   '-Dnode_lib_file=/vercel/.cache/node-gyp/20.12.2/<(target_arch)/node.lib',
16:47:11.925 | .../node_modules/isolated-vm install: gyp info spawn args   '-Dmodule_root_dir=/vercel/path0/node_modules/.pnpm/isolated-vm@5.0.0/node_modules/isolated-vm',
16:47:11.925 | .../node_modules/isolated-vm install: gyp info spawn args   '-Dnode_engine=v8',
16:47:11.925 | .../node_modules/isolated-vm install: gyp info spawn args   '--depth=.',
16:47:11.925 | .../node_modules/isolated-vm install: gyp info spawn args   '--no-parallel',
16:47:11.925 | .../node_modules/isolated-vm install: gyp info spawn args   '--generator-output',
16:47:11.925 | .../node_modules/isolated-vm install: gyp info spawn args   'build',
16:47:11.925 | .../node_modules/isolated-vm install: gyp info spawn args   '-Goutput_dir=.'
16:47:11.925 | .../node_modules/isolated-vm install: gyp info spawn args ]
16:47:12.023 | .../node_modules/isolated-vm install: Traceback (most recent call last):
16:47:12.024 | .../node_modules/isolated-vm install:   File "/pnpm8/node_modules/pnpm/dist/node_modules/node-gyp/gyp/gyp_main.py", line 42, in <module>
16:47:12.024 | .../node_modules/isolated-vm install:     import gyp  # noqa: E402
16:47:12.024 | .../node_modules/isolated-vm install:     ^^^^^^^^^^
16:47:12.024 | .../node_modules/isolated-vm install:   File "/pnpm8/node_modules/pnpm/dist/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 9, in <module>
16:47:12.024 | .../node_modules/isolated-vm install:     import gyp.input
16:47:12.024 | .../node_modules/isolated-vm install:   File "/pnpm8/node_modules/pnpm/dist/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 19, in <module>
16:47:12.024 | .../node_modules/isolated-vm install:     from distutils.version import StrictVersion
16:47:12.024 | .../node_modules/isolated-vm install: ModuleNotFoundError: No module named 'distutils'
16:47:12.032 | .../node_modules/isolated-vm install: gyp ERR! configure error
16:47:12.033 | .../node_modules/isolated-vm install: gyp ERR! stack Error: `gyp` failed with exit code: 1
16:47:12.033 | .../node_modules/isolated-vm install: gyp ERR! stack     at ChildProcess.onCpExit (/pnpm8/node_modules/pnpm/dist/node_modules/node-gyp/lib/configure.js:325:16)
16:47:12.033 | .../node_modules/isolated-vm install: gyp ERR! stack     at ChildProcess.emit (node:events:518:28)
16:47:12.033 | .../node_modules/isolated-vm install: gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
16:47:12.033 | .../node_modules/isolated-vm install: gyp ERR! System Linux 5.10.174
16:47:12.033 | .../node_modules/isolated-vm install: gyp ERR! command "/node20/bin/node" "/pnpm8/node_modules/pnpm/dist/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release" "-j" "max"
16:47:12.034 | .../node_modules/isolated-vm install: gyp ERR! cwd /vercel/path0/node_modules/.pnpm/isolated-vm@5.0.0/node_modules/isolated-vm
16:47:12.034 | .../node_modules/isolated-vm install: gyp ERR! node -v v20.12.2
16:47:12.034 | .../node_modules/isolated-vm install: gyp ERR! node-gyp -v v9.4.1
16:47:12.034 | .../node_modules/isolated-vm install: gyp ERR! not ok
16:47:12.041 | .../node_modules/isolated-vm install: Failed
16:47:12.043 | ELIFECYCLE  Command failed with exit code 1.
16:47:12.113 | Error: Command "pnpm install" exited with 1
16:47:13.087

<br class="Apple-interchange-newline">

Suspected commit: https://github.com/laverdet/isolated-vm/commit/ac5fbde48e5d59e8379861f49e970d98b079fa71

kuon commented 5 months ago

I think distutils was deprecated with python 3.10 and was removed with python 3.12. It seems weird that they removed the setuptool install step in the highlighted commit which was added to fix the issue. But also it is in a github workflow, so I am not sure if it is actually used.

baptisteArno commented 5 months ago

I think distutils was deprecated with python 3.10 and was removed with python 3.12. It seems weird that they removed the setuptool install step in the highlighted commit which was added to fix the issue. But also it is in a github workflow, so I am not sure if it is actually used.

It is used, the script is building the binary that is used in post install script if I am correct!

laverdet commented 4 months ago

The binaries for v4.8.0 are broken. I recommend v5.0.1 which is the same as v4.x except it no longer supports nodejs v16