gpu.js icon indicating copy to clipboard operation
gpu.js copied to clipboard

gpu.js fails to install via npm on Windows with Visual Studio 2022 and later

Open poisonintheink opened this issue 3 years ago • 1 comments

gpu.js up to bat... node-gyp/vs2022: not today. gpu.js up to bat... node-gyp/vs2022: not today.

What is wrong?

(tldr; solution/workaround at the end)

Prefacing by saying I don't consider this a gpu.js issue, but an issue other users may have encountered and struggled with...

  • GPU.JS fails to install on Windows due to incompatibility with Visual Studio 2022 or greater
  • Working back through the issue this stems from [email protected] using [email protected]
  • This version of node-gyp doesn't play nice with VS2022 according to a number of similar Issues posted nodejs/node-gyp
  • Steps to globally update/force node-gyp (eg here) were unsuccessful
  • Similarly configuring msvs_version / VCINSTALLDIR manually was unsuccessful (and started to seem overly intrusive/messy)

How do we replicate the issue?

  • Running a PC with Visual Studio 2022 or higher, with no previous versions of VS installed
  • eg: Visual Studio Community 2022 | Version : 17.2.32516.85
  • npm install (local, global, package.json)

Relevant section of the failure for better context:

807 verbose cwd S:\Projects\gpu-js-install
808 verbose Windows_NT 10.0.22000
809 verbose node v18.6.0
810 verbose npm  v8.13.2
811 error code 1
812 error path S:\Projects\gpu-js-install\node_modules\gl
813 error command failed
814 error command C:\WINDOWS\system32\cmd.exe /d /s /c C:\Users\####\AppData\Local\Temp\install65849247964.cmd
815 error gyp info it worked if it ends with ok
815 error gyp info using [email protected]
815 error gyp info using [email protected] | win32 | x64
815 error gyp info find Python using Python version 2.7.15 found at "C:\Python27\python.exe"
815 error gyp ERR! find VS 
815 error gyp ERR! find VS msvs_version not set from command line or npm config
815 error gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
815 error gyp ERR! find VS unknown version "undefined" found at "S:\Program Files\Microsoft Visual Studio\2022\Community"
815 error gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
815 error gyp ERR! find VS looking for Visual Studio 2015
815 error gyp ERR! find VS - not found
815 error gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
815 error gyp ERR! find VS 
815 error gyp ERR! find VS **************************************************************
815 error gyp ERR! find VS You need to install the latest version of Visual Studio
815 error gyp ERR! find VS including the "Desktop development with C++" workload.
815 error gyp ERR! find VS For more information consult the documentation at:
815 error gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
815 error gyp ERR! find VS **************************************************************

How important is this (1-5)?

  • 0 for myself now that I've worked around it, but might feel like a 5 to those beating their heads against it

Expected behavior (i.e. solution)

  • Issue solved/worked around by using overrides
  • https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides

Working Example 'package.json'

{
  "name": "gpu-js-install",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "gpu.js": "^2.15.0"
  },
  "overrides": {
    "gpu.js": {
      "gl": {
        "node-gyp": ">7.0.0" 
      }
    }
  }
}

poisonintheink avatar Jul 22 '22 13:07 poisonintheink

This is probably the same as https://github.com/gpujs/gpu.js/issues/711

hug0b avatar Jul 27 '22 15:07 hug0b

I believe this is resolved now.

robertleeplummerjr avatar Nov 16 '22 22:11 robertleeplummerjr

There is a similar issue on Arch Linux when running pnpm install

gpu.js version: 2.16

Error output:

.../.pnpm/[email protected]/node_modules/gl install$ prebuild-install || node-gyp rebuild
│ prebuild-install warn install No prebuilt binaries found (target=20.2.0 runtime=node arch=x64 libc= platform=linux)
│ gyp info it worked if it ends with ok
│ gyp info using [email protected]
│ gyp info using [email protected] | linux | x64
│ gyp info find Python using Python version 3.11.3 found at "/usr/bin/python3"
│ gyp info spawn /usr/bin/python3
│ gyp info spawn args [
│ gyp info spawn args   'PROJECT/node_modules/.pnpm/[email protected]/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   'PROJECT/node_modules/.pnpm/[email protected]/node_modules/gl/build/config.gypi',
│ gyp info spawn args   '-I',
│ gyp info spawn args   'PROJECT/node_modules/.pnpm/[email protected]/node_modules/node-gyp/addon.gypi',
│ gyp info spawn args   '-I',
│ gyp info spawn args   '/home/haschtl/.cache/node-gyp/20.2.0/include/node/common.gypi',
│ gyp info spawn args   '-Dlibrary=shared_library',
│ gyp info spawn args   '-Dvisibility=default',
│ gyp info spawn args   '-Dnode_root_dir=/home/haschtl/.cache/node-gyp/20.2.0',
│ gyp info spawn args   '-Dnode_gyp_dir=PROJECT/node_modules/.pnpm/[email protected]/node_modules/node-gyp',
│ gyp info spawn args   '-Dnode_lib_file=/home/haschtl/.cache/node-gyp/20.2.0/<(target_arch)/node.lib',
│ gyp info spawn args   '-Dmodule_root_dir=PROJECT/node_modules/.pnpm/[email protected]/node_modules/gl',
│ 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' ]
│ make: Verzeichnis „PROJECT/node_modules/.pnpm/[email protected]/node_modules/gl/build“ wird betreten
│   CXX(target) Release/obj.target/angle_common/angle/src/common/Float16ToFloat32.o
│ In Datei, eingebunden von ../angle/src/common/debug.h:16,
│                  von ../angle/src/common/mathutil.h:12,
│                  von ../angle/src/common/Float16ToFloat32.cpp:9:
│ ../angle/src/common/angleutils.h:36:14: Fehler: »uintptr_t« bezeichnet keinen Typ
│    36 | extern const uintptr_t DirtyPointer;
│       |              ^~~~~~~~~
│ ../angle/src/common/angleutils.h:21:1: Anmerkung: »uintptr_t« ist im Header »<cstdint>« definiert; haben Sie vergessen, »#include <cstdint>« zu schreiben?
│    20 | #include <vector>
│   +++ |+#include <cstdint>
│    21 | 
│ make: *** [angle/src/angle_common.target.mk:157: Release/obj.target/angle_common/angle/src/common/Float16ToFloat32.o] Fehler 1
│ make: Verzeichnis „PROJECT/node_modules/.pnpm/[email protected]/node_modules/gl/build“ wird verlassen
│ gyp ERR! build error 
│ gyp ERR! stack Error: `make` failed with exit code: 2
│ gyp ERR! stack     at ChildProcess.onExit (PROJECT/node_modules/.pnpm/[email protected]/node_modules/node-gyp/lib/build.js:203:23)
│ gyp ERR! stack     at ChildProcess.emit (node:events:511:28)
│ gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:293:12)
│ gyp ERR! System Linux 6.1.31-2-MANJARO
│ gyp ERR! command "/usr/bin/node" "PROJECT/node_modules/.pnpm/[email protected]/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
│ gyp ERR! cwd PROJECT/node_modules/.pnpm/[email protected]/node_modules/gl
│ gyp ERR! node -v v20.2.0
│ gyp ERR! node-gyp -v v9.4.0
│ gyp ERR! not ok 
└─ Failed in 3.5s at PROJECT/node_modules/.pnpm/[email protected]/node_modules/gl

Adding

  "overrides": {
    "gpu.js": {
      "gl": {
        "node-gyp": ">7.0.0" 
      }
    }
  }

to the package.json solved it for me (I think, because with this override prebuild packages are used?)

Haschtl avatar Jun 21 '23 12:06 Haschtl

I am able to replicate this error with gpu.js 2.16 on Arch Linux with Linux <HOSTNAME> 6.3.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 10 Jun 2023 00:35:35 +0000 x86_64 GNU/Linux.

689 error make: Entering directory '<PROJECT>/node_modules/gl/build'
689 error   CXX(target) Release/obj.target/angle_common/angle/src/common/Float16ToFloat32.o
689 error make: Leaving directory '<PROJECT>/node_modules/gl/build'
690 error prebuild-install warn install No prebuilt binaries found (target=20.2.0 runtime=node arch=x64 libc= platform=linux)
690 error gyp info it worked if it ends with ok
690 error gyp info using [email protected]
690 error gyp info using [email protected] | linux | x64
690 error gyp info find Python using Python version 3.11.3 found at "/usr/bin/python3"
690 error gyp info spawn /usr/bin/python3
690 error gyp info spawn args [
690 error gyp info spawn args   '/home/quantatic/quantatic.github.io/node_modules/node-gyp/gyp/gyp_main.py',
690 error gyp info spawn args   'binding.gyp',
690 error gyp info spawn args   '-f',
690 error gyp info spawn args   'make',
690 error gyp info spawn args   '-I',
690 error gyp info spawn args   '<PROJECT>/node_modules/gl/build/config.gypi',
690 error gyp info spawn args   '-I',
690 error gyp info spawn args   '<PROJECT>/node_modules/node-gyp/addon.gypi',
690 error gyp info spawn args   '-I',
690 error gyp info spawn args   '/home/<USERNAME>/.cache/node-gyp/20.2.0/include/node/common.gypi',
690 error gyp info spawn args   '-Dlibrary=shared_library',
690 error gyp info spawn args   '-Dvisibility=default',
690 error gyp info spawn args   '-Dnode_root_dir=/home/<USERNAME>/.cache/node-gyp/20.2.0',
690 error gyp info spawn args   '-Dnode_gyp_dir=<PROJECT>/node_modules/node-gyp',
690 error gyp info spawn args   '-Dnode_lib_file=/home/<USERNAME>/.cache/node-gyp/20.2.0/<(target_arch)/node.lib',
690 error gyp info spawn args   '-Dmodule_root_dir=<PROJECT>/node_modules/gl',
690 error gyp info spawn args   '-Dnode_engine=v8',
690 error gyp info spawn args   '--depth=.',
690 error gyp info spawn args   '--no-parallel',
690 error gyp info spawn args   '--generator-output',
690 error gyp info spawn args   'build',
690 error gyp info spawn args   '-Goutput_dir=.'
690 error gyp info spawn args ]
690 error gyp info spawn make
690 error gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
690 error In file included from ../angle/src/common/debug.h:16,
690 error                  from ../angle/src/common/mathutil.h:12,
690 error                  from ../angle/src/common/Float16ToFloat32.cpp:9:
690 error ../angle/src/common/angleutils.h:36:14: error: ‘uintptr_t’ does not name a type
690 error    36 | extern const uintptr_t DirtyPointer;
690 error       |              ^~~~~~~~~
690 error ../angle/src/common/angleutils.h:21:1: note: ‘uintptr_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
690 error    20 | #include <vector>
690 error   +++ |+#include <cstdint>
690 error    21 | 
690 error make: *** [angle/src/angle_common.target.mk:159: Release/obj.target/angle_common/angle/src/common/Float16ToFloat32.o] Error 1
690 error gyp ERR! build error 
690 error gyp ERR! stack Error: `make` failed with exit code: 2
690 error gyp ERR! stack     at ChildProcess.onExit (<PROJECT>/node_modules/node-gyp/lib/build.js:203:23)
690 error gyp ERR! stack     at ChildProcess.emit (node:events:511:28)
690 error gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:293:12)
690 error gyp ERR! System Linux 6.3.7-arch1-1
690 error gyp ERR! command "/home/<USERNAME>/.local/share/rtx/installs/node/20.2.0/bin/node" "<PROJECT>/node_modules/.bin/node-gyp" "rebuild"
690 error gyp ERR! cwd <PROJECT>/node_modules/gl
690 error gyp ERR! node -v v20.2.0
690 error gyp ERR! node-gyp -v v9.4.0
690 error gyp ERR! not ok
691 verbose exit 1

I was able to find a number of related issues, for instance, https://bbs.archlinux.org/viewtopic.php?id=285729. Looking at GCC changes, it looks like GCC13 may be the root cause, as per https://gcc.gnu.org/gcc-13/porting_to.html#header-dep-changes.

When running locally, I was able to resolve this by forcing an older version of GCC/G++ as follows:

CC=gcc-11 CXX=g++-11 npm install

quantatic avatar Jun 26 '23 05:06 quantatic