openwallet-foundation / credo-ts

Typescript framework for building decentralized identity and verifiable credential solutions
https://credo.js.org
Apache License 2.0
273 stars 202 forks source link

ffi-napi issue on windows while installation #2061

Open RinkalBhojani opened 1 month ago

RinkalBhojani commented 1 month ago

I am facing below issue on my windows machine while installation.

@TimoGlastra @berendsliedrecht @genaris - Do you have any idea for this?

It fails to build 'ffi-napi' related package.

PS D:\Project\credo-ts> pnpm install Scope: all 19 workspace projects Lockfile is up to date, resolution step is skipped Packages: +1646 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 1646, reused 1646, downloaded 0, added 0, done node_modules/.pnpm/@mattrglobal+node-bbs-signatures@0.18.1/node_modules/@mattrglobal/node-bbs-signatnode_modules/.pnpm/@mattrglobal+node-bbs-signatures@0.18.1/node_modules/@mattrglobal/node-bbs-signatures: Running install script, failed in 1.5s (skipped as optional) node_modules/.pnpm/@2060.io+ffi-napi@4.0.9/node_modules/@2060.io/ffi-napi: Running install script, failed in 6s .../node_modules/@2060.io/ffi-napi install$ node-gyp-build │ D:\Project\credo-ts\node_modules.pnpm\@2060.io+ffi-napi@4.0.9\node_modules\@2060.io\ffi-napi>i…
│ gyp info it worked if it ends with ok │ gyp info using node-gyp@10.1.0 │ gyp info using node@18.20.4 | win32 | x64 │ gyp info find Python using Python version 3.12.6 found at "C:\Users\Rinkal Bhojani\AppData\Loca…
│ gyp info find VS using VS2022 (17.11.35303.130) found at: │ gyp info find VS "C:\Program Files\Microsoft Visual Studio\2022\Community" │ gyp info find VS run with --verbose for detailed information │ gyp info spawn C:\Users\Rinkal Bhojani\AppData\Local\Programs\Python\Python312\python.exe │ gyp info spawn args [ │ gyp info spawn args 'C:\Users\Rinkal Bhojani\AppData\Roaming\npm\node_modules\pnpm\dist…
│ gyp info spawn args 'binding.gyp', │ gyp info spawn args '-f', │ gyp info spawn args 'msvs', │ gyp info spawn args '-I', │ gyp info spawn args 'D:\Project\credo-ts\nodemodules\.pnpm\@2060.io+ffi-napi@4.0.9\node
│ gyp info spawn args '-I', │ gyp info spawn args 'C:\Users\Rinkal Bhojani\AppData\Roaming\npm\node_modules\pnpm\dist…
│ gyp info spawn args '-I', │ gyp info spawn args 'C:\Users\Rinkal Bhojani\AppData\Local\node-gyp\Cache\18.20.4\inclu…
│ gyp info spawn args '-Dlibrary=shared_library', │ gyp info spawn args '-Dvisibility=default', │ gyp info spawn args '-Dnode_root_dir=C:\Users\Rinkal Bhojani\AppData\Local\node-gyp\Cache…
│ gyp info spawn args '-Dnode_gyp_dir=C:\Users\Rinkal Bhojani\AppData\Roaming\npm\node_modu…
│ gyp info spawn args '-Dnode_lib_file=C:\\Users\\Rinkal Bhojani\\AppData\\Local\\node-…
│ gyp info spawn args '-Dmodule_root_dir=D:\Project\credo-ts\node_modules\.pnpm\@2060.io+ffi…
│ 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 'D:\Project\credo-ts\nodemodules\.pnpm\@2060.io+ffi-napi@4.0.9\node
│ gyp info spawn args '-Goutput_dir=.' │ gyp info spawn args ] │ gyp info spawn C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBu…
│ gyp info spawn args [ │ gyp info spawn args 'build\binding.sln', │ gyp info spawn args '/clp:Verbosity=minimal', │ gyp info spawn args '/nologo', │ gyp info spawn args '/p:Configuration=Release;Platform=x64' │ gyp info spawn args ] │ nothing.c │ nothing.vcxproj -> D:\Project\credo-ts\node_modules.pnpm\@2060.io+ffi-napi@4.0.9\node_module…
│ Preprocessing assembly file ......\deps\libffi\src\x86\win64_intel.preasm │ '"call"' is not recognized as an internal or external command, │ operable program or batch file. │ D:\Project\credo-ts\node_modules.pnpm\@2060.io+ffi-napi@4.0.9\node_modules\@2060.io\ffi-napi\b…
│ gyp ERR! build error │ gyp ERR! stack Error: `C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\…
│ gyp ERR! stack at ChildProcess. (C:\Users\Rinkal Bhojani\AppData\Roaming\npm\node_mo…
│ 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 Windows_NT 10.0.19045 │ gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\Rinkal Bhojani\AppData\Roa…
│ gyp ERR! cwd D:\Project\credo-ts\node_modules.pnpm\@2060.io+ffi-napi@4.0.9\node_modules\@2060.…
│ gyp ERR! node -v v18.20.4 │ gyp ERR! node-gyp -v v10.1.0 │ gyp ERR! not ok └─ Failed in 6s at D:\Project\credo-ts\node_modules.pnpm\@2060.io+ffi-napi@4.0.9\node_modules\@2060.io\ffi-napi  ELIFECYCLE  Command failed with exit code 1.

Am I missing something or needs to changed

genaris commented 1 month ago

Maybe this is related to the comment from @btsimonh in https://github.com/nodejs/node/issues/52240#issuecomment-2432473563. I'll check as soon as I can get a Windows machine, but in the meantime probably it may work for you if you force node-gyp-build to version 4.8.2, i.e. add it to package.json's resolutions field:

resolutions: {
...
"node-gyp-build": "4.8.2",
...
}
RinkalBhojani commented 1 month ago

resolutions: { "node-gyp-build": "4.8.2" }

@genaris - I tried this but got the same error.

btsimonh commented 1 month ago

'"call"' is not recognized as an internal or external command,

see the mods I mention in https://github.com/node-ffi-napi/node-ffi-napi/pull/270 - the one about libffi.gyp.

RinkalBhojani commented 2 weeks ago

@genaris @btsimonh - I tried steps given in https://github.com/node-ffi-napi/node-ffi-napi/pull/270 . Still I am getting same error.

I tried these node version v18.19.0 , v20.11.1, v22.11.0.

Could you please help me out with detailed steps to follow?

btsimonh commented 2 weeks ago

Hi @RinkalBhojani,

pls try these repos: "ref-napi": "https://github.com/btsimonh/ref-napi.git", "ref-array-di": "^1.2.2", "ref-struct-di": "^1.1.1", "ffi-napi": "https://github.com/btsimonh/node-ffi-napi.git",

for me, this set is working together for node 22.10.0, and should be ok with 18, 20, 22. It's not tested on <= 16, or on odd numbered node. One test failed for ff-napi, involving a nested 30,000 calls. Once reduced to 15,000, the test is passing.

The changes are a combination of all the resources I could find, plus adapting to use git actions over appveyer. Feel free to use those, or fork them. ffi-napi is a fork of @cclauss version. It include prebuilds for linux, windows, macos x64 macos arm64. I have yet to heavily test them in real environments, but this will be happening soon, as I do need it to work on all those platforms. It does install on windows without needing to build, and it did run my initial tests (accessing windows APIs for an updated version of https://github.com/btsimonh/node-windows-root-certs).

br, Simon