Execute a Shell Script failed (env: node: No such file or directory)

I assume this is an easy fix, but I have searched the forum and the wiki and not found the problem. I am using a keystroke (Cmd-L) to copy the URL from Firefox, assigning it to a variable ("Address") and attempting to access that variable in shell script that calls the clean-mark app, installed by Brew to /usr/local/bin/clean-mark.

In the Execute Shell Script section of the macro, I have this command:

/usr/local/bin/clean-mark "$KMVAR_Address" --stdout

This works perfectly on the command line, where "$KMVAR_Address" is replaced with the URL of the webpage to convert to Markdown. But when I run it in KBM, the script fails with the following error:

Execute a Shell Script failed with script error: env: node: No such file or directory.

Any advice?

Note: this seems to be similar to the (currently unresolved) problem encountered here: Execute Shell Script Help

The Execute a Shell action launches a vanilla shell instance with no connection to or knowledge of your Terminal.app settings.

Here for example, nothing tells it where or what your Node installation is, and it doesn't yet have the requisite PATH settings.

To see what it does have, try:




1 Like

Good idea! I ran the first one and it turns out that PATH only includes /usr/bin:/bin:/usr/sbin:/sbin and node is at /usr/local/bin/node (as are all the other Brew-installed apps).

I have added PATH=$PATH:/usr/local/bin as the first line in my shell script and clean-mark now works, as it is able to find node. Thanks!

Is there a means of setting KBM's default PATH to include /usr/local/bin so I don't need to specify it every time I run a shell script?

1 Like

Others may correct me, but I think we always need to do that explicitly.

(unless, of course, you want to write a custom KM plugin)

Yes. Set ENV_PATH (the Keyboard Maestro Path Variable) prior to the Execute Shell Script Action.
See How To Set a Path

this is easily done manually using the KM Editor Preferences > Variables pane.

1 Like

4 posts were split to a new topic: How Can I Execute KM Shell Script with any KM Variables in the Shell Environment?