Almouro / bitrise-nvm-step

Bitrise step for installing NVM and custom NPM version
http://bitrise.io
MIT License
5 stars 7 forks source link

Lavamoat 'allowScripts', 'postInstall', and 'prepare' do not have root privileges and throws 'permission denied' error #20

Open Any2suited66 opened 1 year ago

Any2suited66 commented 1 year ago

I've posted this issue on bitrise discussions here

This error started occurring right after one of our team members added the NVM step in our workflow using the Android & Docker, on Ubuntu 20.04 Large stack. The command we’re running is yarn install && yarn allow-scripts and it used to work when we added a step to modify the node_modules folder permissions by using chmod -R 777 node_modules but this is not longer working since the NVM step was added. Here is the important part of the log:

Error: command failed
    at ChildProcess.<anonymous> (/bitrise/src/node_modules/@npmcli/promise-spawn/index.js:64:27)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1091:16)
    at Socket.<anonymous> (node:internal/child_process:449:11)
    at Socket.emit (node:events:513:28)
    at Pipe.<anonymous> (node:net:322:12) {
  cmd: 'sh',
  args: [
    '-c',
    'node_modules/.bin/patch-package; node_modules/.bin/rn-nodeify --install events,stream,vm,assert,https,http,os --hack'
  ],
  code: 126,
  signal: null,
  stdout: '',
  stderr: '/tmp/yarn--1685547024439-0.8984727713775877/node: 3: exec: /root/.nvm/versions/node/v18.14.1/bin/node: Permission denied\n' +
    '/tmp/yarn--1685547024439-0.8984727713775877/node: 3: exec: /root/.nvm/versions/node/v18.14.1/bin/node: Permission denied\n',
  event: 'postinstall',
  script: 'node_modules/.bin/patch-package; node_modules/.bin/rn-nodeify --install events,stream,vm,assert,https,http,os --hack',
  pkgid: '',
  path: '/bitrise/src'
}

I have tried other workarounds by applying a trap/catch in the bash script but I still get the same error. I also tried running the commands in the yarn setup manually while using ssh access and they ran without issue but cause other builds to fail. The error only occurs when yarn is trying to run the commands.