In the process of deploying to a Ubuntu 20.04 server
01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
01 yarn install v1.22.19
01 [1/4] Resolving packages...
01 [2/4] Fetching packages...
01 [3/4] Linking dependencies...
01 warning " > [email protected]" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
01 warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
01 [4/4] Building fresh packages...
01 error /home/deploy/mainapp/releases/20230403051422/node_modules/node-sass: Command failed.
[...]
01 gyp verb clean removing "build" directory
01 gyp verb command configure []
01 gyp verb check python checking for Python executable "python2" in the PATH
01 gyp verb `which` failed Error: not found: python2
01 gyp verb `which` failed at getNotFoundError (/home/deploy/mainapp/shared/node_modules/which/which.js:13:12)
...
01 gyp verb check python checking for Python executable "python" in the PATH
01 gyp verb `which` failed Error: not found: python
01 gyp verb `which` failed at getNotFoundError (/home/deploy/mainapp/shared/node_modules/which/which.js:13:12)
[...]
01 gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
01 gyp ERR! stack at PythonFinder.failNoPython (/home/deploy/mainapp/shared/node_modules/node-gyp/lib/configure.js:484:19)
[... concluding with]
01 gyp ERR! command "/usr/bin/node" "/home/deploy/mainapp/shared/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
01 gyp ERR! cwd /home/deploy/mainapp/shared/node_modules/node-sass
01 gyp ERR! node -v v18.15.0
01 gyp ERR! node-gyp -v v3.8.0
01 gyp ERR! not ok
Investigating: /usr/bin has two directories python3 and python3.8. Yet, the deploy seems to hunt for python or python2...
This did not occur on another deployment for the same app on a different machine, still with Ubuntu 20.04.
The intricacies of npm, python and webpack are confounding.
What needs to be done to get the asset precompilation to complete?
As per @Alex comments,
node-gyp 3.8.0is the offending party. why?Using yarn tool why
allows one to climb up the dependencies structure. In this case it was
@rails#webpackerrequiring these elements.Along the way, a number of banana peels are laid out for one's pleasure, convenience and forced learning:
• a pre-set rails application may have the gem version cast. It may be old.
• that gem may, in fact, not be in synch with the content of the
package.jsonsettings.• even then, updating the gem will not percolate to the yarn eco-system
• one can run
yarn installsubsequently on the origin machine & attempt deploy. Odds are development will succeed.• oddly, development and production will not have identical behaviours, at least with respect to CSS (I really never understood why CSS had to be handled like JS - as if they were conceived by the same minds)
• a final cherry on the bananas: production would still not deploy, even though one could successfully execute
yarn installorRAILS_EN=production bundle exec rake assets:precompileon the latest release of the production server• the previous iteration (either or both of yarn install and asset precompilation) was required to finally allow a successful production deployment.