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

Installation instructions are wrong

Open BadIdeaException opened this issue 1 year ago • 1 comments

What is wrong?

As per the installation instructions:

On Linux, ensure you have the correct header files installed: sudo apt install mesa-common-dev libxi-dev (adjust for your distribution) (...) npm install gpu.js --save

On Ubuntu 22.04, this is insufficient to actually install gpu.js. It produces a long error message, at the core of which is npm ERR! /bin/sh: 1: python: not found.

Complete error output: ``` npm ERR! code 1 npm ERR! path /++snip++/node_modules/gl npm ERR! command failed npm ERR! command sh -c prebuild-install || node-gyp rebuild npm ERR! prebuild-install warn install No prebuilt binaries found (target=19.9.0 runtime=node arch=x64 libc= platform=linux) npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using [email protected] npm ERR! gyp info using [email protected] | linux | x64 npm ERR! gyp info find Python using Python version 3.10.6 found at "/usr/bin/python3" npm ERR! gyp info spawn /usr/bin/python3 npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args '/++snip++/node_modules/node-gyp/gyp/gyp_main.py', npm ERR! gyp info spawn args 'binding.gyp', npm ERR! gyp info spawn args '-f', npm ERR! gyp info spawn args 'make', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/++snip++/node_modules/gl/build/config.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/++snip++/node_modules/node-gyp/addon.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/++snip++/.cache/node-gyp/19.9.0/include/node/common.gypi', npm ERR! gyp info spawn args '-Dlibrary=shared_library', npm ERR! gyp info spawn args '-Dvisibility=default', npm ERR! gyp info spawn args '-Dnode_root_dir=/++snip++/.cache/node-gyp/19.9.0', npm ERR! gyp info spawn args '-Dnode_gyp_dir=/++snip++/node_modules/node-gyp', npm ERR! gyp info spawn args '-Dnode_lib_file=/++snip++/.cache/node-gyp/19.9.0/ ## *Where* does it happen? When trying to `npm install` on Ubuntu 22.04.2 LTS, NodeJS 19.9.

How do we replicate the issue?

npm install gpu.js

How important is this (1-5)?

5

Expected behavior (i.e. solution)

Following the installation instructions should install gpu.js.

Other Comments

The issue is, at heart, the same as #814: gpu.js requires Python 2.7 to install, but this is not mentioned anywhere in the install instructions.

In addition, even after installing Python 2.7, the python command will be unrecognized on Ubuntu 22.04. I seem to remember reading that this is a system design decision, Canonical wanting developers to explicitly state the required version (i.e., python2 instead of python) to avoid version ambiguity, but can't find the source anymore. Either way, gpu.js doesn't adhere to that, so you need to manually symlink the python command to Python 2.

sudo apt install python2
sudo ln -s /bin/python2.7 /usr/bin/python

Proposed solution:

Short term fix: Update the docs, so that following the install instructions is actually sufficient to install gpu.js. Long term fix: Update so that gpu.js can be installed using Python 3. Python 2 was sunset over three years ago, coupled with a strong recommendation to migrate to Python 3.

On a related note, it would be great if there was some way to install precompiled versions of gpu.js. This would remove the dependency on Python when shipping software, plus greatly speed up the process.

BadIdeaException avatar Jun 29 '23 07:06 BadIdeaException

For anyone else encountering this, if you don't need the postinstall script to run, you can workaround the issue by adding the following to your package.json. Only tested with yarn.

  "dependenciesMeta": {
    "gl": {
      "built": false
    }
  }

simon-lang avatar Oct 25 '23 06:10 simon-lang