Sublime Forum

Command Line Path

#1

Hi,

When I first wrote my Perforce plugin, I knew Mac users had an issue loading “p4” since their PATH seemed to be ignored, so I added something along the lines of:

def ConstructCommand(in_command):
command = ‘’
if(sublime.platform() == “osx”):
command = 'source ~/.bash_profile && ’
command += in_command
return command

This thread seems to be talking about the same type of issue: viewtopic.php?f=6&t=2252&p=10085&hilit=bash_profile#p10085

I’m now building a new plugin that uses PHP to execute stuff, and since I just got a Mac I decided to try it on. Unfortunately, once again, ST seems to ignore my “.bash_profile”.

Calling “which php” from the Terminal gives me a different answer than calling it from my Python script.

Is there a more elegant solution than what I initially did for my Perforce plugin or should I just stick to it?

Thanks!

Eric

0 Likes

#2

The PATH you set up in your profile only applies to apps you start from the Terminal.

To set an environment variable for gui apps (like Sublime) launched from Finder or Spotlight, you need to edit /etc/launchd.conf and set PATH and reboot your computer. Take a look at http://apple.stackexchange.com/questions/87282/in-mountain-lion-how-do-i-set-the-path-environment-variable-unified-for-all-newl for an example.

I’ve noticed many plugins simply have you set up a configuration parameter that sets the full path to whatever program is needed (p4, php, etc). It’s not as convenient, but as a user I don’t find it too difficult since you only need to do it when you first install the plugin.

0 Likes

#3

That’s very interesting! Thanks

It’s really annoying to be such a “newb” with MacOSX when I spend so many years with DOS/Windows :frowning:

Thanks again!

0 Likes

#4

My plugin, Fix Mac Path, fixes exactly this problem. It modifies ST’s environmental variables, including PATH, to match your shell’s.

Feel free to use it. If you want to incorporate its functionality into your own plugin, ping me and let me know.

0 Likes