cli icon indicating copy to clipboard operation
cli copied to clipboard

postinstall not being executed for pngquant-bin on MacOS

Open oleksii-lukin opened this issue 5 years ago • 7 comments

Current Behavior:

One of subdependencies is pngquant-bin which have postinstall script which is not being executed now

Expected Behavior:

postinstall should execute and generate node_modules/pngquant-bin/vendor/pngquant file

Steps To Reproduce:

Do npm ci for this package.json file https://github.com/llamerr/npm-postinstall-bug and check content of ls node_modules/pngquant-bin/vendor/ as of now, it only contains source folder, but pngquant file is missing

No errors or warnings reported by npm during install from what I see, https://github.com/llamerr/npm-postinstall-bug/blob/master/install.log

It probably started happening after yesterday's upgrade on MacOS. First after I did rm -rf node_modules and npm ci everything broke, so I checked updates and noticed new, upgraded my MacOS, brew, and command line tools. After everything started working again, I still was getting errors in my code which lead me to pngquant bin being missing. I'm using node from nvm if it matters, not sure if I did global packages update (I think I did? At least for some of them, will re-try now), but seems other stuff working fine.

Environment:

OS: MacOS Big Sur 11.2.3 (20D91)

➜ npm-postinstall-bug git:(master) node -v v14.15.3

➜ npm-postinstall-bug git:(master) npm -v 7.6.2

➜ npm-postinstall-bug git:(master) pkgutil --pkg-info=com.apple.pkg.CLTools_Executables

package-id: com.apple.pkg.CLTools_Executables version: 12.4.0.0.1.1610135815 volume: / location: / install-time: 1615403944 groups: com.apple.FindSystemFiles.pkg-group

oleksii-lukin avatar Mar 11 '21 10:03 oleksii-lukin

I removed package-lock.json and did npm i --force again (some packages are incompatible, but seem to work fine) and it did postinstall properly this time. Should I close it or is it still a bug?

oleksii-lukin avatar Mar 11 '21 11:03 oleksii-lukin

@llamerr why should this bug be removed ? I'm having the same issue. on Linux (our CI system) and MacOS.

postinstall just doesn't seem to be reliably executed in v7. I'm noticing this across dozens of projects including eslint and electron.

InputNeuron avatar Mar 28 '21 17:03 InputNeuron

@burtonator I was thinking the issue was that I used force install, so maybe there were some incompatibilities, but that's still strange since I did not see any errors or warnings if I recall correctly.

oleksii-lukin avatar Mar 28 '21 18:03 oleksii-lukin

@llamerr I'm seeing this happen with other packages regardless of ci or install and regardless of package-lock.json or none.

This is happening with electron, eslint, etc. Completely breaking our workflow.

v6 has some serious bugs that we had to avoid so now we're on v7 but there are bugs on v7 we have to avoid too.

InputNeuron avatar Mar 28 '21 18:03 InputNeuron

@llamerr can you try replicating this problem on the latest version of npm? (ie. npm i -g npm) We had a bug at one point in an earlier v7 where package-lock.json was missing some context which could have effected executing lifecycle scripts.

darcyclarke avatar May 07 '21 18:05 darcyclarke

I tried to reproduce it before upgrading, my current versions are:

➜  npm-postinstall-bug git:(master) node -v
v14.16.0
➜  npm-postinstall-bug git:(master) npm -v
6.14.11

and it seems on those versions it's already not reproducing, means working fine

hm... actually I did not remove node_modules before trying it, but checking log, it seems that was done by npm

➜  npm-postinstall-bug git:(master) npm ci
npm WARN prepare removing existing node_modules/ before installation

after npm update (can nvm be related?)

➜  npm-postinstall-bug git:(master) npm i -g npm
/Users/alexey.lukin/.nvm/versions/node/v14.16.0/bin/npm -> /Users/alexey.lukin/.nvm/versions/node/v14.16.0/lib/node_modules/npm/bin/npm-cli.js
/Users/alexey.lukin/.nvm/versions/node/v14.16.0/bin/npx -> /Users/alexey.lukin/.nvm/versions/node/v14.16.0/lib/node_modules/npm/bin/npx-cli.js
+ [email protected]
added 60 packages from 23 contributors, removed 241 packages and updated 194 packages in 6.705s

versions now are

➜  npm-postinstall-bug git:(master) node -v
v14.16.0
➜  npm-postinstall-bug git:(master) npm -v
7.12.0

and now bug is reproduced:

➜  npm-postinstall-bug git:(master) ls node_modules/pngquant-bin/vendor/
source

actually I see that on first try today it was 6.14.11, probably I downgraded it during this time somehow, not sure

oleksii-lukin avatar May 07 '21 19:05 oleksii-lukin

I too am having issues with the postinstall script of a sub-dependency not being called. However when ran with yarn it works as expected.

I have package A that has package B listed as a dependency, package B has a post install hook defined. When package B is installed directly by a project the post install script fires as expected, however when package A is installed the post install script for package B is not being called. I have passed --foreground-scripts to ensure nothing is being missed.

I was initially encountering this on npm v8, so i updated to v9, but i am still facing the exact same issue.

Node version: v18.14.2 npm version: 9.5.0 OS: Mac Ventura 13.0.1 (22A400)

MrTibbles avatar Mar 14 '23 09:03 MrTibbles