Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"WindowsError: [Error 2] The system cannot find the file specified" #148

Closed
the-shank opened this issue Jun 11, 2014 · 2 comments
Closed

Comments

@the-shank
Copy link

I am getting the above error whenever I try running any legit command. Here is the ouput from the terminal.

C:\Users\6008321\git\requisition-tool>legit sync
Traceback (most recent call last):
File "C:\Python27\Scripts\legit-script.py", line 9, in <module>
    load_entry_point('legit==0.1.1', 'console_scripts', 'legit')()
File "C:\Python27\lib\site-packages\legit\cli.py", line 45, in main
    cmd_map.get(arg).__call__(args)
File "C:\Python27\lib\site-packages\legit\cli.py", line 155, in cmd_sync
    if repo.is_dirty():
File "C:\Python27\lib\site-packages\git\repo\base.py", line 502, in is_dirty
    len(self.git.diff('HEAD', '--cached', *default_args)):
File "C:\Python27\lib\site-packages\git\cmd.py", line 227, in <lambda>
    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
File "C:\Python27\lib\site-packages\git\cmd.py", line 456, in _call_process
    return self.execute(call, **_kwargs)
File "C:\Python27\lib\site-packages\git\cmd.py", line 335, in execute
    **subprocess_kwargs
File "C:\Python27\lib\subprocess.py", line 711, in __init__
    errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 948, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

I am on Windows 7.

@the-shank
Copy link
Author

I dug into this further and from this post on StackOverflow, I found the solution.

The problem you see here is that the Windows API function CreateProcess, used by subprocess under the hood, doesn't auto-resolve other executable extensions than .exe. On Windows, the 'git' command is really installed as git.cmd. Therefore, you should modify your example to explicitly invoke git.cmd

So to workaround this issue, all I did is edit the subprocess.py file and convert "git" to "git.cmd" in the args parameter on line 942 and voila it works.

Now if only if someone could direct me in the correct direction (and correct project) to submit a patch for this..

@ghost
Copy link

ghost commented Sep 10, 2016

New version of git for windows (I have 2.9.3) installs git.exe instead of git.cmd, so this shouldn't happen with newer version.

Additionally, a user can select to install Git + optional Unix tools on the path, and that also puts git.exe on the path for older versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants