Skip to content

Commit

Permalink
Some windows path errors if os.environ doesn't contain all values
Browse files Browse the repository at this point in the history
  • Loading branch information
kemayo committed Jan 10, 2016
1 parent 6d3ea79 commit dec201d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions git/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ def find_binary(cmd):
# /usr/local/bin:/usr/local/git/bin
if os.name == 'nt':
extra_paths = (
os.path.join(os.environ["ProgramFiles"], "Git", "bin"),
os.path.join(os.environ["ProgramFiles(x86)"], "Git", "bin"),
os.path.join(os.environ.get("ProgramFiles", ""), "Git", "bin"),
os.path.join(os.environ.get("ProgramFiles(x86)", ""), "Git", "bin"),
)
else:
extra_paths = (
Expand Down Expand Up @@ -205,7 +205,10 @@ def run(self):
except OSError as e:
callback = sublime.error_message
if e.errno == 2:
output = "{cmd} binary could not be found in PATH\n\nConsider using the {cmd_setting}_command setting for the Git plugin\n\nPATH is: {path}".format(cmd=self.command[0], cmd_setting=self.command[0].replace('-', '_'), path=os.environ['PATH'])
global _has_warned
if not _has_warned:
_has_warned = True
output = "{cmd} binary could not be found in PATH\n\nConsider using the {cmd_setting}_command setting for the Git plugin\n\nPATH is: {path}".format(cmd=self.command[0], cmd_setting=self.command[0].replace('-', '_'), path=os.environ['PATH'])
else:
output = e.strerror
finally:
Expand Down

0 comments on commit dec201d

Please sign in to comment.