PATH Considerations for Shell tasks

Hi Folks,

I’ve finally resolved a problem that was plaguing our customers on 10.10 and 11 with our product and Shell processes. Apparent;y, while Apple has forced developers to place external command line tools into /usr/local/bin, they no longer promote that as part of the system PATH variable. Even though the user may see their path as including /usr/local/bin:

$ echo $PATH

The PATH passed to the shell for a Xojo project only contains the default system paths of /bin, /usr/bin, /sbin, and /usr/sbin in 10.10 and 10.11 (and 10.12).

To solve this so you’re not having to update to handle the differences between OS X designs, add this code to your App’s Open event:

    Dim origPath As String = System.EnvironmentVariable("PATH")
    System.EnvironmentVariable("PATH") = "/usr/local/bin:" + origPath

Here’s to hoping that might save some of you Shell frustration down the line.

is path being set in a login script like .bashrc hence why you see it when logging in to terminal ?

It appears that while /usr/local/bin is part of the default path for 10.9 and earlier, it’s not part of it in 10.10+. However, what’s really odd is that none of my test users have a .profile, .bash_profile, or .bashrc file, so they are picking up the modified path from some system setting and that setting is different for users and tasks…

Now that is really odd that it would be different per user & task

I haven’t spent time trying to sort out exactly what apple has messed with from 10.9 to 10.10 to 10.11
They just seem to always think that they should change things

Sort of like SIP in the first place. Non-Apple system tools have to be placed into /usr/local/bin to reduce the exposure for tool replacements like cp or grep, but then they put /usr/local/bin at the front of the users’ path meaning that if malware puts a cp or grep masquerade app there, it will be run instead of the expected tool …