unit icon indicating copy to clipboard operation
unit copied to clipboard

Problem building rpm package in Fedora 38 container running on WSL-2

Open mwoodpatrick opened this issue 2 years ago • 6 comments

With TOT github repo running in podman Fedora 38 container I'm trying to build the rpm package and getting

cd /projects/git/mwoodpatrick/unit/pkg/ make rpm 2>&1 | tee build_rpm.log

build/src/nxt_unit.o build/src/python/nxt_python-python3.10.o build/src/python/nxt_python_asgi-python3.10.o build/src/python/nxt_python_asgi_http-python3.10.o build/src/python/nxt_python_asgi_lifespan-python3.10.o build/src/python/nxt_python_asgi_str-python3.10.o build/src/python/nxt_python_asgi_websocket-python3.10.o build/src/python/nxt_python_wsgi-python3.10.o -L/usr/local/lib/python3.10/config-3.10-x86_64-linux-gnu -L/usr/local/lib -lpython3.10 -lcrypt -ldl -lm -lm /usr/bin/ld: /usr/local/lib/python3.10/config-3.10-x86_64-linux-gnu/libpython3.10.a(abstract.o): relocation R_X86_64_32S against symbol `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: failed to set dynamic section sizes: bad value collect2: error: ld returned 1 exit status make[2]: *** [build/Makefile:2000: build/python3.10.unit.so] Error 1 make[2]: Leaving directory '/projects/git/mwoodpatrick/unit/pkg/rpm/rpmbuild/BUILD/unit-python310-1.28.0' error: Bad exit status from /var/tmp/rpm-tmp.jLNr45 (%build)

build_rpm.log

mwoodpatrick avatar Sep 03 '22 13:09 mwoodpatrick

A couple of things stand out

  • Fedora 38. I'm not sure what that's based on (rawhide snapshot?) as it's not due for release until April next year.
  • The python version is actually older than that in Fedora 36 (latest release), 3.10.5 vs 3.10.6. Also it doesn't look like the system installed version and the use of a static library (libpython3.10.a) looks unusual (certainly the Fedora python-devel packages don't include them).

The Unit python module is building with -fPIC, maybe the python you're building against wasn't?

So you probably have two options

  • Fix your python install.
  • Try Fedora 36 which completes 'make rpm' ok here.

ac000 avatar Sep 03 '22 16:09 ac000

Many thanks for the reply much appreciated. This does work with Fedora 36 and I was able to run the PHP example I hit an error running the node example. I got the following in the log any idea what I'm doing wrong or best way to debug

I do see the file

ls -l /projects/git/mwoodpatrick/podman_systemd/nginx-unit/node/node_modules/unit-http/loader.js -rw-r--r-- 1 user user 794 Sep 3 22:11 /projects/git/mwoodpatrick/podman_systemd/nginx-unit/node/node_modules/unit-http/loader.js

2022/09/04 15:52:03 [info] 62808#62808 "express" prototype started 2022/09/04 15:52:03 [info] 62809#62809 "express" application started node:internal/modules/cjs/loader:936 throw err; ^

Error: Cannot find module 'unit-http/loader' Require stack:

  • internal/preload at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15) at Function.Module._load (node:internal/modules/cjs/loader:778:27) at Module.require (node:internal/modules/cjs/loader:1005:19) at Module._preloadModules (node:internal/modules/cjs/loader:1278:12) at loadPreloadModules (node:internal/bootstrap/pre_execution:474:5) at prepareMainThreadExecution (node:internal/bootstrap/pre_execution:77:3) at node:internal/main/run_main_module:7:1 { code: 'MODULE_NOT_FOUND', requireStack: [ 'internal/preload' ] } 2022/09/04 15:52:03 [notice] 62808#62808 app process (isolated 62809) exited with code 1 2022/09/04 15:52:03 [warn] 62784#62784 failed to start application "express" 2022/09/04 15:52:03 [alert] 62784#62784 failed to apply new conf

mwoodpatrick avatar Sep 04 '22 15:09 mwoodpatrick

I'm not really familiar with node, but one thing you need to do is run

npm link unit-http

Probably as root, proceed with caution, from where to run it, I'm not sure, and don't ask me what it does!

ac000 avatar Sep 07 '22 14:09 ac000

unit-http/loader.js overrides the standard Node.JS loader so that Unit can pass requests to it without requiring modifications to the Node.JS application. So we need to run npm link unit-http for each Node.JS app, in the app's directory.

As it looks like you're using Express, the how-to guide might help: https://unit.nginx.org/howto/express/#express

lcrilly avatar Sep 07 '22 15:09 lcrilly

I fixed that but am now getting an error:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /express</pre>
</body>
</html>

The only thing I see in the log file was a warning:

(node:1731) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time

I do see a node process running:

node --trace-warnings --loader unit-http/loader.mjs --require unit-http/loader app.js

It would really help to have more diagnostic error messages (also see my issue https://github.com/nginx/unit/issues/753

mwoodpatrick avatar Sep 11 '22 14:09 mwoodpatrick

First please keep in mind packaging the Unit Node HTTP module is possible but need to be handled quite carefully. While building the module using node-gyp we are tuning it depending on the current underlaying OS.

So, keep this in mind while packaging the module.

The “Error / Warning” is because we are making use of the ESM load to override the build in HTTP interface of express with the Unit one. As loaders are an experimental feature you are seeing this warning. The error message you received in your browser is an error generated by your application. That means the traffic reached your app. If you still have issues with this I would ask you to create another issue as this problem is not related to the packing.

tippexs avatar Sep 16 '22 17:09 tippexs

build/src/nxt_unit.o build/src/python/nxt_python-python3.10.o build/src/python/nxt_python_asgi-python3.10.o build/src/python/nxt_python_asgi_http-python3.10.o build/src/python/nxt_python_asgi_lifespan-python3.10.o build/src/python/nxt_python_asgi_str-python3.10.o build/src/python/nxt_python_asgi_websocket-python3.10.o build/src/python/nxt_python_wsgi-python3.10.o -L/usr/local/lib/python3.10/config-3.10-x86_64-linux-gnu -L/usr/local/lib -lpython3.10 -lcrypt -ldl -lm -lm /usr/bin/ld: /usr/local/lib/python3.10/config-3.10-x86_64-linux-gnu/libpython3.10.a(abstract.o): relocation R_X86_64_32S against symbol `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: failed to set dynamic section sizes: bad value collect2: error: ld returned 1 exit status

When building Python from source, you do need to configure it with --enable-shared (./configure --enabled-shared)

ac000 avatar Feb 17 '23 22:02 ac000

It's been over a year since any activity on this. Fedora 38 is old news... and this issue seemed to cover multiple topics all of which seem to have been addressed.

ac000 avatar Mar 20 '24 15:03 ac000