matryer / xbar

Put the output from any script or program into your macOS Menu Bar (the BitBar reboot)
https://xbarapp.com
MIT License
17.49k stars 643 forks source link

Xbar Python plugin asdf python not found #856

Open t18n opened 1 year ago

t18n commented 1 year ago

I installed Xbar and github-review-requests but the plugin says "env: python: No such file or directory".

Since I installed python with asdf, the execution path is /Users/me/.asdf/shims/python. I tried to symlink it to usr/bin/python but it doesn't work since MacOS blocks it. I then symlink it to usr/local/bin/python, and changed the plugin header from

#!/usr/bin/env python
# -*- coding: utf-8 -*-

to

#!/usr/local/bin/env python
# -*- coding: utf-8 -*-

but it still doesn't work. Did I miss something?

On an extra node, running

python "/Users/me/Library/Application Support/xbar/plugins/001-github-review-requests.5m.py" 

on the terminal works.

xbar asdf python not found

alexrussell commented 1 year ago

The simplest thing you can do is simply update your shebang to the full path of your python installation, i.e.:

#!/usr/local/bin/env /Users/me/.asdf/shims/python

However, I wanted this to work "portably" across my various computers, which had node (in my case) in different places. asdf-controlled on one, and brew-controlled on another. So, based partly on the advice given in #730 I investigated the env commandline args, and found that -S and -P can work together to "augment" the path for the purposes of the execution. Thus I ended up with:

!/usr/bin/env -S-P/Users/me/.asdf/shims:/usr/local/bin:/usr/bin:${PATH} node

That way asdf node will be found first, if it exists, then /usr/local/bin if it exists, and so on, and we even have whatever PATH xbar plugins get at the end, so we don't clobber that. This works for me.