xbar: jq: command not found, even though installed on system?

my code:

echo -n "E:"; curl -s "https://api.gdax.com/products/ETH-USD/ticker" | jq -r '.bid'
which jq
/usr/local/bin/jq

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16

Most upvoted comments

Provide the absolute path to jq:

which -a jq will show something like e.g.:

>>> /usr/local/bin/jq

Now instead of jq -r ".bid"' use /usr/local/bin/jq -r ".bid"

Why should I use an absolute path?

Because xbar/bitbar does not use your user’s $PATH environment, and instead uses a restricted env that does not include /usr/local/bin in the $PATH (similar to the env crontab uses). If you do want to use your user’s environment then do it explicitly at the top of the script with source ~/.bashrc (if using bash) or source ~/.zshrc (if using zsh) — but be aware that this might slow down your scripts depending on what you have in your shell config files. A better, safer and faster alternative would be to put at the top of your script

export PATH=/usr/local/bin:$PATH

Aha, I missed your |. Try this /usr/bin/sudo -u you -i bash -c 'echo -n "E:"; curl -s "https://api.gdax.com/products/ETH-USD/ticker" | jq -r ".bid"'