microsoft / node-pty

Fork pseudoterminals in Node.JS
Other
1.42k stars 233 forks source link

node-gyp does not appear to be available in GH actions anymore #633

Closed johrstrom closed 9 months ago

johrstrom commented 9 months ago

Environment details

Issue description

node-gyp doesn't appear to be available in Github actions anymore. I'm not quite sure when this changed, but our builds started to fail maybe a week ago with this error below (it was flaky for some time, but now reliably fails).

Basically trying to install this package failed because node-gyp does not appear to be in the PATH.

```shell tmp/node_modules/yarn/bin/yarn --production install --flat --cache-folder /home/runner/.cache/yarn/ood-shell-app yarn install v1.22.19 [1/4] Resolving packages... warning Lockfile has incorrect entry for "ms@2.0.0". Ignoring it. warning Lockfile has incorrect entry for "inherits@2.0.4". Ignoring it. warning Lockfile has incorrect entry for "ms@2.1.3". Ignoring it. [2/4] Fetching packages... [3/4] Linking dependencies... [4/4] Building fresh packages... error /home/runner/work/ondemand/ondemand/apps/shell/node_modules/node-pty: Command failed. Exit code: 1 Command: node scripts/install.js Arguments: Directory: /home/runner/work/ondemand/ondemand/apps/shell/node_modules/node-pty Output: node:events:495 throw er; // Unhandled 'error' event ^ Error: spawn node-gyp ENOENT at ChildProcess._handle.onexit (node:internal/child_process:284:19) at onErrorNT (node:internal/child_process:477:16) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) Emitted 'error' event on ChildProcess instance at: at ChildProcess._handle.onexit (node:internal/child_process:290:12) at onErrorNT (node:internal/child_process:477:16) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { errno: -2, code: 'ENOENT', syscall: 'spawn node-gyp', path: 'node-gyp', spawnargs: [ 'rebuild' ] } ```

The fix was just to add a step like so

     - name: Setup Node.js
        run: |
          npm install -g node-gyp

This issue is half a heads up as others may encounter the same, the other half wondering why it's not a dependency? I would guess there's an assumption that the nodejs you've installed through your system package manager also installed this module?

In any case - feel free to close as it really is just a informational ticket to let folks know should they run into the same issue. (I could setup a simple CI to demonstrate the same and can do so if you like/need).

Tyriar commented 9 months ago

It's not a dependency as I'm pretty sure node-gyp used to be bundled with node.js, we might need to change that

johrstrom commented 9 months ago

OK weird - I setup a test repository (https://github.com/johrstrom/test_node_gyp) (just to make sure I'm not insane) and see this message - which I don't see in the code base that I'm getting this error out of.

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.

And since it says that - it works because it automatically installed it.

Tyriar commented 9 months ago

It's probably due to thius https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20

johrstrom commented 9 months ago

OK - I cannot replicate the issue in a simple demonstrative project. It acknowledges that node-gyp is not there and installs it.

image

Not really sure why my original project doesn't have the same behavior, but it's clearly an environmental issue.

johrstrom commented 9 months ago

OH! got it to replicate using version 0.9.0. Maybe all I have to do is update lol. Sorry for the noise - I thought it would be helpful in case other users see the same.

johrstrom commented 9 months ago

Feel free to close this as it doesn't even seem to impact 1.0.0 and users on 0.9.0 have a workaround.

IDK if there's anything to be done on your side - but I'm more of a ruby developer so there could be some node.js nuance I'm missing.