cozy-labs / cozy-desktop

File Synchronisation for Cozy on Desktop and Laptop
https://cozy-labs.github.io/cozy-desktop/
GNU Affero General Public License v3.0
98 stars 45 forks source link

Building failure #2206

Closed ArchangeGabriel closed 2 years ago

ArchangeGabriel commented 2 years ago

Description

cozy-desktop (3.31 or 3.32 tested) fails to build on Arch Linux. I lacked time to report before (at 3.32 release), but nothing changed since then. Wondering if the old electron version used could be the issue.

Steps to Reproduce

yarn install
yarn build --offline
yarn dist --dir

Expected behavior

Build succeed.

Actual behavior

yarn run v1.22.17
$ electron-builder build --dir
  • electron-builder  version=22.8.1 os=5.16.9-arch1-1
  • loaded configuration  file=/build/cozy-desktop/src/cozy-desktop-3.32.0/electron-builder.yml
  • rebuilding native dependencies  dependencies=@atom/watcher@1.3.5-0, dtrace-provider@0.8.8, leveldown@5.6.0 platform=linux arch=x64
  • install prebuilt binary  name=@atom/watcher version=1.3.5-0 platform=linux arch=x64
  • build native dependency from sources  name=@atom/watcher
                                          version=1.3.5-0
                                          platform=linux
                                          arch=x64
                                          reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
                                          error=prebuild-install info begin Prebuild-install version 5.3.3
    prebuild-install info looking for cached prebuild @ /build/.npm/_prebuilds/fadfed-watcher-v1.3.5-0-electron-v87-linux-x64.tar.gz
    prebuild-install http request GET https://github.com/atom/watcher/releases/download/v1.3.5-0/watcher-v1.3.5-0-electron-v87-linux-x64.tar.gz
    prebuild-install http 404 https://github.com/atom/watcher/releases/download/v1.3.5-0/watcher-v1.3.5-0-electron-v87-linux-x64.tar.gz
    prebuild-install WARN install No prebuilt binaries found (target=12.2.1 runtime=electron arch=x64 libc= platform=linux)

  • rebuilding native dependency  name=dtrace-provider version=0.8.8
  • rebuilding native dependency  name=@atom/watcher version=1.3.5-0
  • rebuilding native dependency  name=leveldown version=5.6.0
  ⨯ cannot execute  cause=exit status 1
                    out=$ prebuild-install || node-gyp rebuild
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

                    errorOut=prebuild-install WARN install No prebuilt binaries found (target=12.2.1 runtime=electron arch=x64 libc= platform=linux)
    gyp info it worked if it ends with ok
    gyp info using node-gyp@9.0.0
    gyp info using node@16.13.2 | linux | x64
    gyp info find Python using Python version 3.10.2 found at "/usr/bin/python3"
    gyp http GET https://electronjs.org/headers/v12.2.1/node-v12.2.1-headers.tar.gz
    gyp http 200 https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist/v12.2.1/node-v12.2.1-headers.tar.gz
    gyp http GET https://electronjs.org/headers/v12.2.1/SHASUMS256.txt
    gyp http 200 https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist/v12.2.1/SHASUMS256.txt
    gyp info spawn /usr/bin/python3
    gyp info spawn args [
    gyp info spawn args   '/usr/lib/node_modules/node-gyp/gyp/gyp_main.py',
    gyp info spawn args   'binding.gyp',
    gyp info spawn args   '-f',
    gyp info spawn args   'make',
    gyp info spawn args   '-I',
    gyp info spawn args   '/build/cozy-desktop/src/cozy-desktop-3.32.0/node_modules/@atom/watcher/build/config.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   '/usr/lib/node_modules/node-gyp/addon.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   '/build/.electron-gyp/12.2.1/include/node/common.gypi',
    gyp info spawn args   '-Dlibrary=shared_library',
    gyp info spawn args   '-Dvisibility=default',
    gyp info spawn args   '-Dnode_root_dir=/build/.electron-gyp/12.2.1',
    gyp info spawn args   '-Dnode_gyp_dir=/usr/lib/node_modules/node-gyp',
    gyp info spawn args   '-Dnode_lib_file=/build/.electron-gyp/12.2.1/<(target_arch)/node.lib',
    gyp info spawn args   '-Dmodule_root_dir=/build/cozy-desktop/src/cozy-desktop-3.32.0/node_modules/@atom/watcher',
    gyp info spawn args   '-Dnode_engine=v8',
    gyp info spawn args   '--depth=.',
    gyp info spawn args   '--no-parallel',
    gyp info spawn args   '--generator-output',
    gyp info spawn args   'build',
    gyp info spawn args   '-Goutput_dir=.'
    gyp info spawn args ]
    gyp: name 'openssl_fips' is not defined while evaluating condition 'openssl_fips != ""' in binding.gyp 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/lib/node_modules/node-gyp/lib/configure.js:261:16)
    gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
    gyp ERR! System Linux 5.16.9-arch1-1
    gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "rebuild"
    gyp ERR! cwd /build/cozy-desktop/src/cozy-desktop-3.32.0/node_modules/@atom/watcher
    gyp ERR! node -v v16.13.2
    gyp ERR! node-gyp -v v9.0.0
    gyp ERR! not ok 
    error Command failed with exit code 1.

                    command=/usr/bin/node /usr/lib/node_modules/yarn/bin/yarn.js run install
                    workingDir=/build/cozy-desktop/src/cozy-desktop-3.32.0/node_modules/@atom/watcher
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Informations

taratatach commented 2 years ago

I see differences in some package versions between what we use and what you use:

Although I manage to build the app with your specific versions, could you try we the other versions?

taratatach commented 2 years ago

Or maybe I'm misreading the building logs and you're actually trying to build on Node v17? In which case, this would be a known issue (see https://github.com/electron/electron/issues/32114) and going back to Node v16 would be enough.

ArchangeGabriel commented 2 years ago

No you read the log correctly. I was pretty sure I tried node v14 too (when 3.32 was released, not recently I reckon), but trying it (again?) now worked (so maybe something else changed in the meantime). But then I tried again v16 just in case (failed), reverted back to v14… and it failed. Re-retried, failed again. So since it worked once I actually got a built package and I’m going to publish this one, but the issue is not really solved.

Regarding node-gyp I don’t have control over its version (it’s the one packaged in Arch).

taratatach commented 2 years ago

It's weird about node-gyp. This is a dependency of the project and thus its version is set in yarn.lock. I don't understand why another version is used. I'm out of ideas unfortunately. The only references I've seen to this specific error were related to Node v17. I'll keep looking, just in case. I would try building it on Arch myself but I've never used this distro so I think I'd be lost.

ArchangeGabriel commented 2 years ago

Well yarn.lock has node-gyp@^5.0.4, so any version above 5.0.4 is accepted from my understanding of ^ in node ecosystem. So the version available on the system is considered filling that dependency I guess.

I’ve subscribed to the electron ticket you’ve linked, will see what happens from there.

taratatach commented 2 years ago

From https://semver.npmjs.com/, package versions using ^ (carret) will « include everything that does not increment the first non-zero portion of semver ». So ^5.0.4 should only include patches above 5.0.4, not minor nor major version updates.

Besides, since the version of node-gyp is fixed to 5.0.5 by our yarn.lock file, yarn should install this specific version and the build scripts use it.

ArchangeGabriel commented 2 years ago

Thanks for that reference, so I was not right about this (but note that in my understanding, a minor would be accepted as that “does not increment the first non-zero portion of semver” —which here is only the 5—, the non-zero part seems to be more for something like whatever@^0.2.3 that should not increase the 2).

So I’ve made several attempts for packaging the new 3.33 release. Without changing anything, the build still fails (don’t want to try several attempts to see if it sometimes work as it did for 3.32).

By looking at verbose log, I see node-gyp 5.0.5 is actually downloaded (Performing "GET" request to "https://registry.yarnpkg.com/node-gyp/-/node-gyp-5.0.5.tgz"). But I guess system version is used nonetheless?

I’ve tried removing the system installed node-gyp, the result of yarn install was this:

yarn install v1.22.17
[1/5] Validating package.json...
[2/5] Resolving packages...
warning Resolution field "nan@2.14.0" is incompatible with requested version "nan@2.14.1"
warning Resolution field "node-abi@3.2.0" is incompatible with requested version "node-abi@^2.7.0"
[3/5] Fetching packages...
[4/5] Linking dependencies...
warning " > cozy-client@27.14.0" has unmet peer dependency "react-native@^0.65.0".
warning " > cozy-client@27.14.0" has unmet peer dependency "react-native-google-safetynet@npm:cozy-react-native-google-safetynet@^1.0.0".
warning " > cozy-client@27.14.0" has unmet peer dependency "react-native-inappbrowser-reborn@^3.5.1".
warning " > cozy-client@27.14.0" has unmet peer dependency "react-native-ios11-devicecheck@https://github.com/cozy/react-native-devicecheck#app-attest-v0.1".
warning " > cozy-ui@35.38.0" has unmet peer dependency "@material-ui/core@3.9.4".
warning " > cozy-ui@35.38.0" has incorrect peer dependency "cozy-client@^13.4.0".
warning " > cozy-ui@35.38.0" has unmet peer dependency "cozy-device-helper@1.10.0".
warning " > cozy-ui@35.38.0" has unmet peer dependency "cozy-doctypes@^1.69.0".
warning " > cozy-ui@35.38.0" has unmet peer dependency "piwik-react-router@^0.8.2".
warning " > cozy-ui@35.38.0" has unmet peer dependency "preact@^8.3.1".
warning " > cozy-ui@35.38.0" has unmet peer dependency "preact-portal@^1.1.3".
warning " > cozy-ui@35.38.0" has unmet peer dependency "puppeteer@1.20.0".
warning "cozy-ui > react-pdf > pdfjs-dist@2.1.266" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0-alpha.0 || ^4.0.0".
warning "cozy-ui > react-pdf > pdfjs-dist > worker-loader@2.0.0" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0-alpha.0 || ^4.0.0".
warning " > request-promise@4.2.4" has unmet peer dependency "request@^2.34".
warning " > eslint-plugin-node@8.0.1" has unmet peer dependency "eslint@>=4.19.1".
warning "eslint-plugin-node > eslint-plugin-es@1.4.1" has unmet peer dependency "eslint@>=4.19.1".
[5/5] Building fresh packages...
info This package requires node-gyp, which is not currently installed. Yarn will attempt to automatically install it. If this fails, you can run "yarn global add node-gyp" to manually install it.
[1/4] Resolving packages...
error /build/cozy-desktop/src/cozy-desktop-3.33.0/node_modules/@atom/watcher: Command failed.
Exit code: 127
Command: prebuild-install || node-gyp rebuild
Arguments: 
Directory: /build/cozy-desktop/src/cozy-desktop-3.33.0/node_modules/@atom/watcher
Output:
prebuild-install WARN install No prebuilt binaries found (target=14.19.0 runtime=node arch=x64 libc= platform=linux)
/bin/sh: line 1: node-gyp: command not found
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "node-gyp@9.0.0" with binaries:
      - node-gyp

So, from what I see it tries (and manage to, but apparently not at the right time) to download node-gyp… 9.0.0.

I’ve tried to have verbose log of the build and dist step but --verbose does not work there. However in doing so, I’ve also wondered if --offline during build could be an issue… and guess what, it is. Removing that bit is making the build succeed (though this is considered a bad packaging practice per our standards and at some point in the future network might be removed during the build step). I’m very puzzled by that since the dist step is the failing one, not build, but I guess something earlier is done differently and that changes the end result.

Interestingly, trying to use our system installed electron in the dist call (args are forwarded to electron-builder) results in the same error even without --offline. So I guess this has to do with how some of our packages are compiled, and in the end everything converge towards that electron bug. You can close here if you want as I don’t really think anything could be done on your side.

taratatach commented 2 years ago

Hey. The funny thing is I just encountered the same issue locally while trying to build the project from a fresh clone. While rebuilding the atom/watcher dependency, node-gyp v9.0.0 is also being used!

It turns out, Electron prior to v13 is not generating a valid config.gypi file. This was not used by node-gyp to build modules until v8.4.0 where it becomes a build failure source.

I couldn't figure out why node-gyp v9.0.0 is being used or why the build doesn't fail on my main clone or the CI but I figured out how to build using the new node-gyp version. Simply add this before you run yarn dist : export npm_config_force_process_config=true.

For more details, see:

taratatach commented 2 years ago

OK, I got the answer. When building the app's native dependencies, electron-builder executes node-gyp as a program. It apparently calls the global node-gyp installed by npm and thus its version depends on the npm version. At least that's how node-gyp v9.0.0 is available on my machine as I did not install it myself and the version in the project's node_modules is not used.

New versions of electron-builder already include the mitigation I posted above but there were issues in newer versions that prevented us from upgrading. I'll revisit this once I get the time.

ArchangeGabriel commented 2 years ago

On my side I forgot to update you that this issue seemed more severe than expected, because the build cozy-desktop does not work actually (I’ve observed that myself and it was also reported by several users to @clochix). The observed behaviour is precisely that the watcher does nothing (the client runs but no sync occurs at all), so I guess this is entirely related.

With your above addition I now have a very different error:

yarn run v1.22.18
$ electron-builder build --dir
  • electron-builder  version=22.8.1 os=5.16.16-arch1-1
  • loaded configuration  file=/build/cozy-desktop/src/cozy-desktop-3.33.0/electron-builder.yml
  • rebuilding native dependencies  dependencies=@atom/watcher@1.3.5-0, dtrace-provider@0.8.8, leveldown@5.6.0 platform=linux arch=x64
  • install prebuilt binary  name=@atom/watcher version=1.3.5-0 platform=linux arch=x64
  • build native dependency from sources  name=@atom/watcher
                                          version=1.3.5-0
                                          platform=linux
                                          arch=x64
                                          reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
                                          error=prebuild-install info begin Prebuild-install version 5.3.3
    prebuild-install info looking for cached prebuild @ /build/.npm/_prebuilds/fadfed-watcher-v1.3.5-0-electron-v87-linux-x64.tar.gz
    prebuild-install http request GET https://github.com/atom/watcher/releases/download/v1.3.5-0/watcher-v1.3.5-0-electron-v87-linux-x64.tar.gz
    prebuild-install http 404 https://github.com/atom/watcher/releases/download/v1.3.5-0/watcher-v1.3.5-0-electron-v87-linux-x64.tar.gz
    prebuild-install WARN install No prebuilt binaries found (target=12.2.1 runtime=electron arch=x64 libc= platform=linux)

  • rebuilding native dependency  name=dtrace-provider version=0.8.8
  • rebuilding native dependency  name=@atom/watcher version=1.3.5-0
  • rebuilding native dependency  name=leveldown version=5.6.0
  ⨯ cannot execute  cause=exit status 1
                    out=$ prebuild-install || node-gyp rebuild
    make: Entering directory '/build/cozy-desktop/src/cozy-desktop-3.33.0/node_modules/@atom/watcher/build'
      CXX(target) Release/obj.target/watcher/src/binding.o
      CXX(target) Release/obj.target/watcher/src/hub.o
      CXX(target) Release/obj.target/watcher/src/log.o
      CXX(target) Release/obj.target/watcher/src/errable.o
      CXX(target) Release/obj.target/watcher/src/queue.o
      CXX(target) Release/obj.target/watcher/src/lock.o
      CXX(target) Release/obj.target/watcher/src/message.o
      CXX(target) Release/obj.target/watcher/src/message_buffer.o
      CXX(target) Release/obj.target/watcher/src/thread_starter.o
      CXX(target) Release/obj.target/watcher/src/thread.o
      CXX(target) Release/obj.target/watcher/src/status.o
      CXX(target) Release/obj.target/watcher/src/worker/worker_thread.o
      CXX(target) Release/obj.target/watcher/src/worker/recent_file_cache.o
      CXX(target) Release/obj.target/watcher/src/polling/directory_record.o
      CXX(target) Release/obj.target/watcher/src/polling/polled_root.o
      CXX(target) Release/obj.target/watcher/src/polling/polling_iterator.o
      CXX(target) Release/obj.target/watcher/src/polling/polling_thread.o
      CXX(target) Release/obj.target/watcher/src/helper/libuv.o
      CXX(target) Release/obj.target/watcher/src/nan/async_callback.o
      CXX(target) Release/obj.target/watcher/src/nan/all_callback.o
      CXX(target) Release/obj.target/watcher/src/nan/functional_callback.o
      CXX(target) Release/obj.target/watcher/src/nan/options.o
      CXX(target) Release/obj.target/watcher/src/helper/common_posix.o
      CXX(target) Release/obj.target/watcher/src/worker/linux/pipe.o
      CXX(target) Release/obj.target/watcher/src/worker/linux/side_effect.o
      CXX(target) Release/obj.target/watcher/src/worker/linux/cookie_jar.o
      CXX(target) Release/obj.target/watcher/src/worker/linux/watched_directory.o
      CXX(target) Release/obj.target/watcher/src/worker/linux/watch_registry.o
      CXX(target) Release/obj.target/watcher/src/worker/linux/linux_worker_platform.o
    make: Leaving directory '/build/cozy-desktop/src/cozy-desktop-3.33.0/node_modules/@atom/watcher/build'
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

                    errorOut=prebuild-install WARN install No prebuilt binaries found (target=12.2.1 runtime=electron arch=x64 libc= platform=linux)
    gyp info it worked if it ends with ok
    gyp info using node-gyp@9.0.0
    gyp info using node@14.19.1 | linux | x64
    gyp info find Python using Python version 3.10.4 found at "/usr/bin/python3"
    gyp http GET https://electronjs.org/headers/v12.2.1/node-v12.2.1-headers.tar.gz
    gyp http 200 https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist/v12.2.1/node-v12.2.1-headers.tar.gz
    gyp http GET https://electronjs.org/headers/v12.2.1/SHASUMS256.txt
    gyp http 200 https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist/v12.2.1/SHASUMS256.txt
    gyp info spawn /usr/bin/python3
    gyp info spawn args [
    gyp info spawn args   '/usr/lib/node_modules/node-gyp/gyp/gyp_main.py',
    gyp info spawn args   'binding.gyp',
    gyp info spawn args   '-f',
    gyp info spawn args   'make',
    gyp info spawn args   '-I',
    gyp info spawn args   '/build/cozy-desktop/src/cozy-desktop-3.33.0/node_modules/@atom/watcher/build/config.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   '/usr/lib/node_modules/node-gyp/addon.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   '/build/.electron-gyp/12.2.1/include/node/common.gypi',
    gyp info spawn args   '-Dlibrary=shared_library',
    gyp info spawn args   '-Dvisibility=default',
    gyp info spawn args   '-Dnode_root_dir=/build/.electron-gyp/12.2.1',
    gyp info spawn args   '-Dnode_gyp_dir=/usr/lib/node_modules/node-gyp',
    gyp info spawn args   '-Dnode_lib_file=/build/.electron-gyp/12.2.1/<(target_arch)/node.lib',
    gyp info spawn args   '-Dmodule_root_dir=/build/cozy-desktop/src/cozy-desktop-3.33.0/node_modules/@atom/watcher',
    gyp info spawn args   '-Dnode_engine=v8',
    gyp info spawn args   '--depth=.',
    gyp info spawn args   '--no-parallel',
    gyp info spawn args   '--generator-output',
    gyp info spawn args   'build',
    gyp info spawn args   '-Goutput_dir=.'
    gyp info spawn args ]
    gyp info spawn make
    gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
    In file included from ../src/nan/async_callback.cpp:1:
    ../../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
    ../../../nan/nan.h:2298:7: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
     2298 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
          |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from ../src/nan/functional_callback.cpp:3:
    ../../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
    ../../../nan/nan.h:2298:7: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
     2298 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
          |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../src/nan/functional_callback.cpp: In function ‘void _fn_callback_helper(const Nan::FunctionCallbackInfo<v8::Value>&)’:
    ../src/nan/functional_callback.cpp:27:47: warning: ‘v8::ArrayBuffer::Contents v8::ArrayBuffer::GetContents()’ is deprecated: Use GetBackingStore. See http://crbug.com/v8/9908. [-Wdeprecated-declarations]
       27 |   Contents cb_contents = cb_array->GetContents();
          |                          ~~~~~~~~~~~~~~~~~~~~~^~
    In file included from /build/.electron-gyp/12.2.1/include/node/node.h:67,
                     from ../../../nan/nan.h:54,
                     from ../src/nan/functional_callback.cpp:3:
    /build/.electron-gyp/12.2.1/include/node/v8.h:5494:12: note: declared here
     5494 |   Contents GetContents();
          |            ^~~~~~~~~~~
    In file included from ../src/binding.cpp:2:
    ../../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
    ../../../nan/nan.h:2298:7: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
     2298 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
          |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../src/nan/functional_callback.cpp: In function ‘std::unique_ptr<AsyncCallback> fn_callback(const char*, FnCallback&)’:
    ../src/nan/functional_callback.cpp:45:21: warning: ‘static v8::Local<v8::ArrayBuffer> v8::ArrayBuffer::New(v8::Isolate*, void*, size_t, v8::ArrayBufferCreationMode)’ is deprecated: Use the version that takes a BackingStore. See http://crbug.com/v8/9908. [-Wdeprecated-declarations]
       45 |     ArrayBuffer::New(Isolate::GetCurrent(), static_cast<void *>(payload), sizeof(FnCallback *));
          |     ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from /build/.electron-gyp/12.2.1/include/node/node.h:67,
                     from ../../../nan/nan.h:54,
                     from ../src/nan/functional_callback.cpp:3:
    /build/.electron-gyp/12.2.1/include/node/v8.h:5397:29: note: declared here
     5397 |   static Local<ArrayBuffer> New(
          |                             ^~~
    In file included from ../src/nan/options.cpp:1:
    ../../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
    ../../../nan/nan.h:2298:7: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
     2298 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
          |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../src/worker/linux/cookie_jar.cpp:17:1: error: declaration of ‘Cookie::Cookie(ChannelID, std::string&&, EntryKind) noexcept’ has a different exception specifier
       17 | Cookie::Cookie(ChannelID channel_id, std::string &&from_path, EntryKind kind) noexcept :
          | ^~~~~~
    In file included from ../src/worker/linux/cookie_jar.cpp:11:
    ../src/worker/linux/cookie_jar.h:20:3: note: from previous declaration ‘Cookie::Cookie(ChannelID, std::string&&, EntryKind)’
       20 |   Cookie(ChannelID channel_id, std::string &&from_path, EntryKind kind);
          |   ^~~~~~
    In file included from ../src/hub.cpp:3:
    ../../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
    ../../../nan/nan.h:2298:7: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
     2298 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
          |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from ../src/nan/all_callback.cpp:3:
    ../../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
    ../../../nan/nan.h:2298:7: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
     2298 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
          |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    make: *** [watcher.target.mk:147: Release/obj.target/watcher/src/worker/linux/cookie_jar.o] Error 1
    make: *** Waiting for unfinished jobs....
    In file included from ../../../nan/nan.h:54,
                     from ../src/binding.cpp:2:
    ../src/binding.cpp: At global scope:
    /build/.electron-gyp/12.2.1/include/node/node.h:770:7: warning: cast between incompatible function types from ‘void (*)(v8::Local<v8::Object>)’ to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
      770 |       (node::addon_register_func) (regfunc),                          \
          |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /build/.electron-gyp/12.2.1/include/node/node.h:804:3: note: in expansion of macro ‘NODE_MODULE_X’
      804 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
          |   ^~~~~~~~~~~~~
    ../src/binding.cpp:218:1: note: in expansion of macro ‘NODE_MODULE’
      218 | NODE_MODULE(watcher, initialize);  // NOLINT
          | ^~~~~~~~~~~
    ../src/hub.cpp: In member function ‘void Hub::handle_events_from(Thread&)’:
    ../src/hub.cpp:214:20: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’, declared with attribute ‘warn_unused_result’ [-Wunused-result]
      214 |       js_event->Set(Nan::GetCurrentContext(),
          |       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
      215 |         Nan::New<String>("action").ToLocalChecked(),
          |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      216 |         Nan::New<Number>(static_cast<int>(fs->get_filesystem_action())));
          |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from /build/.electron-gyp/12.2.1/include/node/node.h:67,
                     from ../../../nan/nan.h:54,
                     from ../src/hub.cpp:3:
    /build/.electron-gyp/12.2.1/include/node/v8.h:3851:37: note: declared here
     3851 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
          |                                     ^~~
    ../src/hub.cpp:217:20: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’, declared with attribute ‘warn_unused_result’ [-Wunused-result]
      217 |       js_event->Set(Nan::GetCurrentContext(),
          |       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
      218 |         Nan::New<String>("kind").ToLocalChecked(),
          |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      219 |         Nan::New<Number>(static_cast<int>(fs->get_entry_kind())));
          |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from /build/.electron-gyp/12.2.1/include/node/node.h:67,
                     from ../../../nan/nan.h:54,
                     from ../src/hub.cpp:3:
    /build/.electron-gyp/12.2.1/include/node/v8.h:3851:37: note: declared here
     3851 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
          |                                     ^~~
    ../src/hub.cpp:220:20: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’, declared with attribute ‘warn_unused_result’ [-Wunused-result]
      220 |       js_event->Set(Nan::GetCurrentContext(),
          |       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
      221 |         Nan::New<String>("oldPath").ToLocalChecked(),
          |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      222 |         Nan::New<String>(fs->get_old_path()).ToLocalChecked());
          |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from /build/.electron-gyp/12.2.1/include/node/node.h:67,
                     from ../../../nan/nan.h:54,
                     from ../src/hub.cpp:3:
    /build/.electron-gyp/12.2.1/include/node/v8.h:3851:37: note: declared here
     3851 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
          |                                     ^~~
    ../src/hub.cpp:223:20: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’, declared with attribute ‘warn_unused_result’ [-Wunused-result]
      223 |       js_event->Set(Nan::GetCurrentContext(),
          |       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
      224 |         Nan::New<String>("path").ToLocalChecked(),
          |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      225 |         Nan::New<String>(fs->get_path()).ToLocalChecked());
          |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from /build/.electron-gyp/12.2.1/include/node/node.h:67,
                     from ../../../nan/nan.h:54,
                     from ../src/hub.cpp:3:
    /build/.electron-gyp/12.2.1/include/node/v8.h:3851:37: note: declared here
     3851 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
          |                                     ^~~
    ../src/hub.cpp:319:20: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, uint32_t, v8::Local<v8::Value>)’, declared with attribute ‘warn_unused_result’ [-Wunused-result]
      319 |       js_array->Set(Nan::GetCurrentContext(), index, js_event);
          |       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from /build/.electron-gyp/12.2.1/include/node/node.h:67,
                     from ../../../nan/nan.h:54,
                     from ../src/hub.cpp:3:
    /build/.electron-gyp/12.2.1/include/node/v8.h:3854:37: note: declared here
     3854 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
          |                                     ^~~
    gyp ERR! build error 
    gyp ERR! stack Error: `make` failed with exit code: 2
    gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/node-gyp/lib/build.js:194:23)
    gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
    gyp ERR! System Linux 5.16.16-arch1-1
    gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "rebuild"
    gyp ERR! cwd /build/cozy-desktop/src/cozy-desktop-3.33.0/node_modules/@atom/watcher
    gyp ERR! node -v v14.19.1
    gyp ERR! node-gyp -v v9.0.0
    gyp ERR! not ok 
    error Command failed with exit code 1.

                    command=/usr/bin/node /usr/lib/node_modules/yarn/bin/yarn.js run install
                    workingDir=/build/cozy-desktop/src/cozy-desktop-3.33.0/node_modules/@atom/watcher
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This seems closely related to the proposed changed by @loqs (an awesome Arch contributor actually) in https://github.com/atom/watcher/issues/242#issuecomment-1066001517=. I don’t know how I could integrate that patch in the process, but that could be a local mitigation for this.

This is going to be an issue for you too at some point, because as you perfectly know from the linked ticket, the atom watcher does not work with electron 13+ and the project is now completely dead (as is atom itself actually, which does not build on anything newer than electron 9 so both packages are going to be removed from Arch very soon —ironic when you think electron was developed initially for and together with atom)… electron 12.x has been EOL for a while now, 13.x is EOL too, and 14.x will likely soon be with the release of 18… tomorrow. Not saying it’s easy, as a packager of several electron dependent projects I know how complicated things can be, though I have no knowledge of electron, js or node whatsoever… Maybe there is some replacement for atom watcher, that would likely be (even if an huge work) the more future proof approach.

ArchangeGabriel commented 2 years ago

So @loqs actually provided the way to add this patch:

diff --git a/src/worker/linux/cookie_jar.h b/src/worker/linux/cookie_jar.h
index 05d33a3..8c36879 100644
--- a/src/worker/linux/cookie_jar.h
+++ b/src/worker/linux/cookie_jar.h
@@ -17,7 +17,7 @@
 class Cookie
 {
 public:
-  Cookie(ChannelID channel_id, std::string &&from_path, EntryKind kind);
+  Cookie(ChannelID channel_id, std::string &&from_path, EntryKind kind) noexcept;
   Cookie(Cookie &&other) noexcept;
   ~Cookie() = default;

into the Arch package (https://bugs.archlinux.org/task/74134), which combined with node-gyp subtlety made it compile and work.

taratatach commented 2 years ago

Awesome. Thanks for all the info and happy that all is well now.