rails / webpacker

Use Webpack to manage app-like JavaScript modules in Rails
MIT License
5.31k stars 1.47k forks source link

Replace the error message 'Node.js not installed' when 'which_command' is not installed #3246

Closed katorres02 closed 2 years ago

katorres02 commented 2 years ago

I have a custom Centos docker image with a ruby on rails project setup. I was getting the following error during the precompile task.

bundle exec rails assets:precompile

this is the error output:

.
.
.
I, [2021-12-21T17:28:19.287300 ]  INFO -- : Writing /usr/local/project/public/assets/express/lib/application-98f164ad65010340ab481475a0137ee982cf4de44f0e4c6441263ebb2b671.js.gz
sh: which: command not found
sh: which: command not found
Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/
Exiting!

The command '/bin/sh -c PRECOMPILE_ASSETS_FLAG=true RAILS_GROUPS=assets bundle exec rake assets:precompile' returned a non-zero code: 1

The final message indicates that Node.js is not installed which is incorrect. Node is already installed and working, the problem here is my Centos image doesn't have the "which" command activated/installed.

According to the GNU error codes: https://www.gnu.org/software/libc/manual/html_node/Error-Codes.html The error Errno::ENOSYS will be more accurate for this scenario.

Macro: int ENOSYS “Function not implemented.” This indicates that the function called is not implemented at all, either in the C library itself or in the operating system.

Please review this Pull Request and consider changing the error message for this scenario

justin808 commented 2 years ago

@katorres02 could you test out using type rather than which in your PR?