Open tulioag opened 4 years ago
The command is used for detecting all the frontend tools used, node, bower, npm, pnpm, webpack ... While the failure is visible, it will not have any effect as this is just "overly verbose way" of indicating that we were not able to discover the used tool and will install it in almost all cases.
But it seems that there might be some undesired side effects from which
so it should not be used.
Changing to use command -v
instead of which
makes the output differ and that would require changing the logic in which the tools are located, so it would require some rework. At least in TC all unit tests trying to locate anything would start to fail.
So in case we discover how using which
will actually be broken or cause undesired side effects, this does not seem like a priority thing to do.
I did some further investigation on that issue using these images.
docker run -it maven:3-jdk-8 which ls
docker run -it maven:3-jdk-8 command -v ls
docker run -it maven:3-jdk-8 sh -c 'command -v ls'
docker run -it maven:latest which ls
docker run -it maven:latest command -v ls
docker run -it maven:latest sh -c 'command -v ls'
docker run -it maven:alpine which ls
docker run -it maven:alpine command -v ls
docker run -it maven:alpine sh -c 'command -v ls'
The only command that worked on all was sh -c 'command -v ls'
, because command
is in many cases a shell builtin.
which
is available on Debian and Alpine, but not on Oracle Linux. command
is available as a standalone command only on Oracle Linux, but is always present at least as a shell builtin.
I get several exceptions like this when trying to build a project on a docker image.
The build still continues running after the exceptions, it is unclear to me what are the effects.
According to this answer https://stackoverflow.com/a/677212 ,
command -v
would be a more portable alternative towhich
.The issue can be reproduced by building an image based in this Dockerfile
Example exception