chrissimpkins / glue

Glue is a plugin that joins your shell to Sublime Text in quasi-perfect harmony.
http://gluedocs.readthedocs.org/
MIT License
253 stars 10 forks source link

Any reason for not using `os.environ['PATH']`? #3

Closed FichteFoll closed 10 years ago

FichteFoll commented 10 years ago

The instructions say that I need to set my system PATH in the settings, but why do I need to do that at all? Python has free access to environment variables.

It would make sense to allow a custom path setting for glue but in that case the default should still be the system path.

chrissimpkins commented 10 years ago

I really like that idea a lot @FichteFoll . I am aware of the capability in Python but haven't had a chance to test it across multiple platforms in the Python 2.6 (ST2) and Python 3.3 (ST3) versions. I've already found that the os.getcwd() method that I use for the {{pwd}} extension template tag is failing in Windows. For some reason, the directory path returns without OS specific separators in the Python 2.6 version (ST2) on Windows, but it seems to work in the Python 3.3 version (ST3) on Windows.

I went with the more onerous, explicit approach to avoid problems with the initial release of the plugin. I will add this to the queue and do some testing to confirm that the PATH that is returned works. Would you happen to be using Windows? I am doing my Windows testing through a Parallels install which is not optimal.

chrissimpkins commented 10 years ago

SO discussion for future reference:

http://stackoverflow.com/questions/1681208/python-platform-independent-way-to-modify-path-environment-variable

FichteFoll commented 10 years ago

Yes, I am using Windows.

chrissimpkins commented 10 years ago

Can you confirm that Python 3.3 and Python 2.6 return your correct PATH settings? Are they in a semicolon delimited list?

Thanks much!

On Mar 31, 2014, at 11:53 AM, FichteFoll notifications@github.com wrote:

Yes, I am using Windows.

— Reply to this email directly or view it on GitHub.

FichteFoll commented 10 years ago

Yes, I can confirm that the results of import os; os.environ['path'] of ST2 and ST3 are equal and a semicolon-delimited list (and they are correct).

chrissimpkins commented 10 years ago

Thanks much. I will test in Linux and Unix and get this implemented. Greatly appreciate the suggestion!

chrissimpkins commented 10 years ago

Made these changes and added the ability to choose your default shell as well. The Python PATH settings are correct for Windows and Linux. They are not set correctly in Mac OSX but the defaults that are assigned will catch most system executables and I will make sure that Mac users are notified that they will likely need to update their settings. I added a new glue path command that allows you to easily view the default PATH that Glue is using because it can differ from what is returned with echo $PATH. Unclear why there is this issue with Python in ST. It happens in both ST2 and ST3, but not with the Python 2 or 3 interpreter when it is run from a terminal outside of ST...

Doing some testing tonight and should be available by tomorrow. Thanks again for the suggestion.