Home Download Buy Blog Forum Support

Command Line Path

Command Line Path

Postby emartel on Sat Aug 03, 2013 6:53 pm

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
emartel
 
Posts: 23
Joined: Thu Feb 23, 2012 8:59 pm
Location: Montreal, Canada

Re: Command Line Path

Postby sapphirehamster on Sat Aug 03, 2013 7:21 pm

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.
sapphirehamster
 
Posts: 88
Joined: Sun Jul 01, 2012 11:19 pm

Re: Command Line Path

Postby emartel on Sat Aug 03, 2013 8:05 pm

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 :(

Thanks again!
emartel
 
Posts: 23
Joined: Thu Feb 23, 2012 8:59 pm
Location: Montreal, Canada

Re: Command Line Path

Postby int3h on Fri Aug 09, 2013 6:42 am

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.
int3h
 
Posts: 3
Joined: Thu Jul 18, 2013 2:24 am


Return to Plugin Development

Who is online

Users browsing this forum: Google [Bot], gustebeast, Majestic-12 [Bot] and 5 guests