How can I fix this bizarre "No such file or directory" error when building with make on Mac?

Viewed 368

I have a Node.js Native Addon C++ library, which uses node-gyp to generate a Makefile and then compiles and links the library using that Makefile. I am encountering this strange error: approximately once every 20 runs or so, a build fails with an error that starts with sh: and then says that a seemingly random system binary or shell builtin cannot be found in a seemingly random directory from the path. For example, a recent error message says this:

sh: /Users/kbuilder/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin/printf: No such file or directory

Here are some other variants I have seen:

sh: /Library/Frameworks/Python.framework/Versions/3.5/bin/touch: No such file or directory
sh: /Users/kbuilder/.nvm/versions/node/v10.19.0/bin/rm: No such file or directory
sh: /Users/kbuilder/.rvm/gems/ruby-2.6.3@global/bin/printf: No such file or directory

Some other error messages that seem to be related are:

/bin/sh: /bin/sh: cannot execute binary file

and

make: /bin/sh: Exec format error

What is happening here and how can I fix it?

0 Answers
Related