VladCuciureanu / Toothpick

🔎 Observe and control Bluetooth devices. Connecting to your devices has never been faster. A @raycast extension.
13 stars 4 forks source link

blueutil is not found when installed with homebrew in custom path #1

Closed oranja closed 10 months ago

oranja commented 10 months ago

Hello, First of all thanks for the cool extension!

I am using this on my work laptop and workplace recommends installing Homebrew under /home/$USER/ folder instead of the usual folder. This causes an incompatibility with blueutil since the current code searches for it only in a few predefined locations: https://github.com/VladCuciureanu/Toothpick/blob/5d686189288b0a47c50f3ce247b4fb4e1fa581ad/src/core/devices/devices.service.blueutil.ts#L6C2-L6C2

Perhaps the which command can be used instead/first to see if blueutil is known in any of the system's search paths (i.e. listed in $PATH)? which is an ancient builtin command that should be available on every MacOS version that Raycast supports (12+).

VladCuciureanu commented 10 months ago

Hey!

I looked into this and, as expected, 'which' can't be used for finding the location of 'blueutil'. This is because the shell created for child_process.exec is a stripped down one. As far as I know, this policy is on MacOS's SIP side so there's not much I can do on that side.

The only fix to your issue that I could come up with is providing the option to override the exec's directory. This way you can use custom locations for 'blueutil' and still provide out-of-the-box compatibility with most machines.

If, for example, 'blueutil' is at '/home/oranja/.bin/blueutil', you should set the preference to '/home/oranja/.bin'.

This option is gonna come out with the next release.

oranja commented 10 months ago

@VladCuciureanu, thanks for looking into this and thanks for finding a creative solution! Tested on my system with my custom homebrew/binpath and it worked perfectly :)