Skip to content

"distutils not found" (when installing modules needing node-gyp) #195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bobpaul opened this issue Feb 4, 2025 · 3 comments
Open

"distutils not found" (when installing modules needing node-gyp) #195

bobpaul opened this issue Feb 4, 2025 · 3 comments

Comments

@bobpaul
Copy link

bobpaul commented Feb 4, 2025

While building the docker image for ppc64le I ran into a snag where the sqlite3 node module wasn't properly installed, but this didn't cause the image to fail building and I did not notice until things were running:

$ docker compose up
[+] Running 1/1
 ✔ Container thelounge  Created                                                                                                                                                                                                                                           0.1s
Attaching to thelounge
thelounge  | 2025-02-04 18:23:35 [ERROR] Unable to load sqlite3 module. See https://github.com/mapbox/node-sqlite3/wiki/Binaries
thelounge  | 2025-02-04 18:23:36 [INFO] The Lounge v4.4.3 (Node.js 18.20.6 on linux ppc64)
thelounge  | 2025-02-04 18:23:36 [INFO] Configuration file: /var/opt/thelounge/config.js
thelounge  | 2025-02-04 18:23:36 [INFO] Available at http://[::]:9000/ in private mode
thelounge  | 2025-02-04 18:23:36 [INFO] User bobpaul loaded
thelounge  | 2025-02-04 18:23:46 [WARN] WebPush subscription for bobpaul returned an error (410), removing subscription
thelounge  | 2025-02-04 18:23:46 [WARN] WebPush subscription for bobpaul returned an error (410), removing subscription

While troubleshooting I found that yarn --non-interactive --frozen-lockfile global add [email protected] was "succeeding" without sqlite:

gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
Traceback (most recent call last):
  File \"/usr/local/share/.config/yarn/global/node_modules/node-gyp/gyp/gyp_main.py\", line 42, in <module>
    import gyp  # noqa: E402
    ^^^^^^^^^^
  File \"/usr/local/share/.config/yarn/global/node_modules/node-gyp/gyp/pylib/gyp/__init__.py\", line 9, in <module>
    import gyp.input
  File \"/usr/local/share/.config/yarn/global/node_modules/node-gyp/gyp/pylib/gyp/input.py\", line 19, in <module>
    from distutils.version import StrictVersion
ModuleNotFoundError: No module named 'distutils'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/share/.config/yarn/global/node_modules/node-gyp/lib/configure.js:259:16)
gyp ERR! stack     at ChildProcess.emit (node:events:517:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:292:12)
gyp ERR! System Linux 6.12.10-arch1-1-4k
gyp ERR! command \"/usr/local/bin/node\" \"/usr/local/share/.config/yarn/global/node_modules/sqlite3/node_modules/.bin/node-gyp\" \"rebuild\"
gyp ERR! cwd /usr/local/share/.config/yarn/global/node_modules/sqlite3
gyp ERR! node -v v18.20.6
gyp ERR! node-gyp -v v8.4.1
success Installed "[email protected]" with binaries:
      - thelounge
Done in 16.82s.

Adding py-setuptools to the list of build-deps allows it to complete. It also looks like the symlink to /usr/bin/python is no longer necessary, as the python3 package on alpine already does this.

IMHO the gyp ERR! should cause the yarn global add command to fail so that the docker build fails, but I don't see an argument that would cause that behavior.

@brunnre8
Copy link
Member

brunnre8 commented Feb 4, 2025

IMHO the gyp ERR! should cause the yarn global add command to fail so that the docker build fails, but I don't see an argument that would cause that behavior.

sqlite is an optional dep, so this behavior is expected and in fact a "feature".

I'm with you personally and would rather just mandate sqlite but that is a bit funny if you don't actually use sqlite as a user and don't give a damn if it works or not (say public mode or simply with text logs)

So yeah, runtime error it is essentially.

@bobpaul
Copy link
Author

bobpaul commented Feb 22, 2025

Well, be that as it may, I do think the Dockerfile should build correctly on any platform alpine supports (otherwise why include build-essentials in the first place?) The current Dockerfile still works "accidentally" on arm/x86 because pre-compiled blobs for the sqlite module exist upstream. With the PR anyone should be able to docker build . regardless of their host platform.

@brunnre8
Copy link
Member

can you directly send a PR our way adding the dep?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants