I have a call (“mercury-parser” via Yarn, using the full path to the call) that converts Web pages to lines of structured text (the page used in the call describes the service):
/Users/me/.yarn/bin/mercury-parser https://postlight.com/trackchanges/mercury-goes-open-source
If I run it in Terminal (using either /bin/bash or /bin/sh on a 2013 Mac Pro, macOS 10.14.5), I get the proper result: fourteen lines of structured text from the Web page.
However, the very same call returns an error when run as a single-line, “do shell script” AppleScript:
do shell script "/Users/me/.yarn/bin/mercury-parser https://postlight.com/trackchanges/mercury-goes-open-source"
The error returned is:
error "env: node: No such file or directory" number 127
FWIW, here are both my .profile and my .bash_profile texts (the latter created solely to try and solve this quandary), that should not be necessary, given that the full path to the call is being specified, specifically to avoid such an error:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
[[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh # This loads NVM
source ~/.nvm/nvm.sh
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
What do I have to do to get the call to run as an AppleScript?
[2019.6.26 at 11:25:45PM: Edited in an attempt at clarification.]
2019.6.27 at 1:36:57PM: Per Mark’s suggestion:
Thank you, Mark; I duplicated my .[bash_]profile, renamed it to “.bashrc”, and added “bin/bash” to the call:
do shell script "bin/bash; /Users/RF/.yarn/bin/mercury-parser https://postlight.com/trackchanges/mercury-goes-open-source"
However, (after a reboot) I still get the same error:
error "env: node: No such file or directory" number 127
Thoughts?
do shell script
does not. You either need to add the relevant init steps to thedo shell script
section, or add them to .bashrc (which runs for non-login shells). It's for reasons like this that it's common to either have .bash_profile run .bashrc (and put the init script steps in .bashrc) or vice versa. But you should rewrite it so it doesn't add things toPATH
over & over. See this question.