cheery / node-udev

Bindings to libudev
35 stars 31 forks source link

ValueError: invalid mode: 'rU' while trying to load binding.gyp #43

Open raintonr opened 1 year ago

raintonr commented 1 year ago

Fails to install on Fedora FC38.

node v18.16.0 npm 6.14.8 python 3.11.3

Possible solution: https://stackoverflow.com/questions/74715990/node-gyp-err-invalid-mode-ru-while-trying-to-load-binding-gyp

$ npm i udev

> @serialport/bindings-cpp@11.0.1 install /opt/iobroker/node_modules/@serialport/bindings-cpp
> node-gyp-build

> unix-dgram@2.0.6 install /opt/iobroker/node_modules/unix-dgram
> node-gyp rebuild

(node:7023) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
(Use `node --trace-deprecation ...` to show where the warning was created)
Traceback (most recent call last):
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 50, in <module>
    sys.exit(gyp.script_main())
             ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 554, in script_main
    return main(sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 547, in main
    return gyp_main(args)
           ^^^^^^^^^^^^^^
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 520, in gyp_main
    [generator, flat_list, targets, data] = Load(
                                            ^^^^^
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 136, in Load
    result = gyp.input.Load(build_files, default_variables, includes[:],
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 2782, in Load
    LoadTargetBuildFile(build_file, data, aux_data,
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 391, in LoadTargetBuildFile
    build_file_data = LoadOneBuildFile(build_file_path, data, aux_data,
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 234, in LoadOneBuildFile
    build_file_contents = open(build_file_path, 'rU').read()
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid mode: 'rU' while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Linux 6.3.4-201.fc38.x86_64
gyp ERR! command "/usr/bin/node-18" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /opt/iobroker/node_modules/unix-dgram
gyp ERR! node -v v18.16.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
cheery commented 1 year ago

Hi, I will update the library in case there's a need, however it seems the problem is in the node gyp itself now.

It's possible node-udev needs a fix on the configuration files. But I'd first like you to isolate the problem. Can you see whether the issue happens with any other library that uses gyp? If it does, there's a problem with gyp, otherwise it's a problem with node-udev (and I get an example on fixing it properly).

la 3. kesäk. 2023 klo 11.29 Robin Rainton @.***> kirjoitti:

Fails to install on Fedora FC38.

node v18.16.0 npm 6.14.8 python 3.11.3

Possible solution: https://stackoverflow.com/questions/74715990/node-gyp-err-invalid-mode-ru-while-trying-to-load-binding-gyp

$ npm i udev

@@. install @./bindings-cpp node-gyp-build

@.*** install /opt/iobroker/node_modules/unix-dgram node-gyp rebuild

(node:7023) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only. (Use node --trace-deprecation ... to show where the warning was created) Traceback (most recent call last): File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 50, in sys.exit(gyp.script_main()) ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/init.py", line 554, in script_main return main(sys.argv[1:]) ^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/init.py", line 547, in main return gyp_main(args) ^^^^^^^^^^^^^^ File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/init.py", line 520, in gyp_main [generator, flat_list, targets, data] = Load( ^^^^^ File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/init.py", line 136, in Load result = gyp.input.Load(build_files, default_variables, includes[:], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 2782, in Load LoadTargetBuildFile(build_file, data, aux_data, File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 391, in LoadTargetBuildFile build_file_data = LoadOneBuildFile(build_file_path, data, aux_data, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 234, in LoadOneBuildFile build_file_contents = open(build_file_path, 'rU').read() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: invalid mode: 'rU' while trying to load binding.gyp gyp ERR! configure error gyp ERR! stack Error: gyp failed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16) gyp ERR! stack at ChildProcess.emit (node:events:513:28) gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:291:12) gyp ERR! System Linux 6.3.4-201.fc38.x86_64 gyp ERR! command "/usr/bin/node-18" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /opt/iobroker/node_modules/unix-dgram gyp ERR! node -v v18.16.0 gyp ERR! node-gyp -v v5.1.0 gyp ERR! not ok

— Reply to this email directly, view it on GitHub https://github.com/cheery/node-udev/issues/43, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJIXPAUVZSRXSYS53VV2A3XJLYV7ANCNFSM6AAAAAAYZE4M74 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

raintonr commented 1 year ago

Do you have a specific test package in mind? FWIW, just triked to npm i nan which failed with the same error so maybe you are correct.

All I know is udev doesn't work here so looking for a solution. If that is to wait for a fix in gyp (do you see an issue logged awaiting resolution?) then so be it.

cheery commented 1 year ago

They seem to be aware of it, and the fix may come in next version. https://github.com/nodejs/node-gyp/issues/2219

Python files are easy to edit. Maybe you could edit the file in question and fix it that way. I'm reading it's a change of a flag kind of thing.

Another option is running the gyp in downgraded python environment.

su 4. kesäk. 2023 klo 8.07 Robin Rainton @.***> kirjoitti:

Do you have a specific test package in mind? FWIW, just triked to npm i nan which failed with the same error so maybe you are correct.

All I know is udev doesn't work here so looking for a solution. If that is to wait for a fix in gyp (do you see an issue logged awaiting resolution?) then so be it.

— Reply to this email directly, view it on GitHub https://github.com/cheery/node-udev/issues/43#issuecomment-1575393246, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJIXPC4A4J6WTFSIFE5RGDXJQJZXANCNFSM6AAAAAAYZE4M74 . You are receiving this because you commented.Message ID: @.***>