You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(trojan) C:\trojan>Scripts\pre-commit.exe run
Traceback (most recent call last):
File "C:\trojan\Scripts\pre-commit-script.py", line 9, in <module>
load_entry_point('pre-commit==0.2.8', 'console_scripts', 'pre-commit')()
File "C:\trojan\lib\site-packages\pkg_resources.py", line 356, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "C:\trojan\lib\site-packages\pkg_resources.py", line 2431, in load_entry_point
return ep.load()
File "C:\trojan\lib\site-packages\pkg_resources.py", line 2147, in load
['__name__'])
File "C:\trojan\lib\site-packages\pre_commit\main.py", line 12, in <module>
from pre_commit.commands.run import run
File "C:\trojan\lib\site-packages\pre_commit\commands\run.py", line 11, in <module>
from pre_commit.output import get_hook_message
File "C:\trojan\lib\site-packages\pre_commit\output.py", line 11, in <module>
['tput', 'cols'], stdout=subprocess.PIPE
File "C:\Python27\Lib\subprocess.py", line 710, in __init__
errread, errwrite)
File "C:\Python27\Lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Using git-shell (from github's windows downloads), I have pre-commit running! A bunch of the tests fail however and I'm not convinced that using github's tools constitutes supporting windows. But worst-case you can start using some of the hooks. I'm going to keep working on this branch and get more things passing.
I think it's msysgit
This is the error I'm getting:
(virtualenv) C:\project > pre-commit run --all-files
[INFO]←[0m Installing environment for git://github.com/pre-commit/pre-commit-hooks.
[INFO]←[0m Once installed this environment will be reused.
[INFO]←[0m This may take a few minutes...
An unexpected error has occurred: CalledProcessError: Command: ['bash', '-c', ". 'C:\\Documents and Settings\\IEUser\\.pre-commit\\repoobvhtq\\py_env\\Scripts\\activate' && cd 'C:\\Documents and Settings\\IEUser\\.pre-commit\\repoobvhtq\\' && pip install ."]
Return code: 1
Expected return code: 0
Output: (none)
Errors: (none)
Check the log at ~/.pre-commit/pre-commit.log
I don't know where to find the log mentioned in the last line:
(virtualenv) C:\project > cd ~
The system cannot find the path specified.
Ah I see the issue. Under Windows XP, msysgit's install doesn't provide an executable named bash. I was however able to get this running and working with "git bash". Does what work for you?
I in fact do have some version of bash installed (I think I also have git bash installed, I'm not quite sure how to tell which is which).
I've found the log, which isn't much more explanatory:
An unexpected error has occurred: CalledProcessError: Command: ['bash', '-c', ". 'C:\\Documents and Settings\\IEUser\\.pre-commit\\repoobvhtq\\py_env\\Scripts\\activate' && cd 'C:\\Documents and Settings\\IEUser\\.pre-commit\\repoobvhtq\\' && pip install ."]
Return code: 1
Expected return code: 0
Output: (none)
Errors: (none)
Traceback (most recent call last):
File "C:\trojan\lib\site-packages\pre_commit\error_handler.py", line 34, in error_handler
yield
File "C:\trojan\lib\site-packages\pre_commit\main.py", line 129, in main
return run(runner, args)
File "C:\trojan\lib\site-packages\pre_commit\commands\run.py", line 165, in run
return _run_hooks(runner, args, write=write, environ=environ)
File "C:\trojan\lib\site-packages\pre_commit\commands\run.py", line 115, in _run_hooks
for repo in runner.repositories:
File "C:\trojan\lib\site-packages\cached_property.py", line 26, in __get__
value = obj.__dict__[self.func.__name__] = self.func(obj)
File "C:\trojan\lib\site-packages\pre_commit\runner.py", line 43, in repositories
repository.require_installed()
File "C:\trojan\lib\site-packages\pre_commit\repository.py", line 64, in require_installed
self.install()
File "C:\trojan\lib\site-packages\pre_commit\repository.py", line 96, in install
language.install_environment(self.cmd_runner, language_version)
File "C:\trojan\lib\site-packages\pre_commit\languages\python.py", line 51, in install_environment
env.run("cd '{prefix}' && pip install .")
File "C:\trojan\lib\site-packages\pre_commit\languages\helpers.py", line 42, in run
['bash', '-c', ' '.join([self.env_prefix, cmd])], **kwargs
File "C:\trojan\lib\site-packages\pre_commit\prefixed_command_runner.py", line 41, in run
return cmd_output(*replaced_cmd, __popen=self.__popen, **kwargs)
File "C:\trojan\lib\site-packages\pre_commit\util.py", line 160, in cmd_output
returncode, cmd, retcode, output=(stdout, stderr),
CalledProcessError: Command: ['bash', '-c', ". 'C:\\Documents and Settings\\IEUser\\.pre-commit\\repoobvhtq\\py_env\\Scripts\\activate' && cd 'C:\\Documents and Settings\\IEUser\\.pre-commit\\repoobvhtq\\' && pip install ."]
Return code: 1
Expected return code: 0
Output: (none)
Errors: (none)
Running the command manually doesn't give many hints:
(virtualenv) C:\project>bash -c . 'C:\\Documents and Settings\\IEUser\\.pre-commit\\repoobvhtq\\py_env\\Scripts\\activate' && cd 'C:\\Documents and Settings\\IEUser\\.pre-commit\\repoobvhtq\\' && pip install .
(virtualenv) C:\project>echo %errorlevel%
1
With cmd.
Looks like it's working with git bash, (some hooks run, others don't, it's complaining about not finding the correct pep8 version, but that's another story).
Thanks ! Will use git bash from now on !
(for reference here is the pep8 issue I'm getting)
Traceback (most recent call last):
File "c:\DOCUME~1\IEUser\PRE-CO~1\REPOOB~1\py_env\Scripts\end-of-file-fixer-script.py", line 5, in <module>
from pkg_resources import load_entry_point
File "C:\DOCUME~1\IEUser\PRE-CO~1\REPOOB~1\py_env\lib\site-packages\pkg_resources.py", line 2829, in <module>
working_set = WorkingSet._build_master()
File "C:\DOCUME~1\IEUser\PRE-CO~1\REPOOB~1\py_env\lib\site-packages\pkg_resources.py", line 451, in _build_master
return cls._build_from_requirements(__requires__)
File "C:\DOCUME~1\IEUser\PRE-CO~1\REPOOB~1\py_env\lib\site-packages\pkg_resources.py", line 464, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "C:\DOCUME~1\IEUser\PRE-CO~1\REPOOB~1\py_env\lib\site-packages\pkg_resources.py", line 639, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pep8>=1.5.7,<1.6
It'd be possible, but I'd rather not bundle all of msysgit when on windows I can expect most if not all of it to be installed :) (plus then I'd have to deal with the licensing issue)
(though it's possible it does actually work and I'm just doing something wrong)
When I try to use pre-commit in cmder I get this even though cmder supposedly has msysgit bundled in:
Fix double quoted strings................................................Failed
hookid: double-quote-string-fixer
C:\Users\gkisel\.pre-commit\repodxm4yi\py_env\Scripts\activate: line 62: basename: command not found
C:\Users\gkisel\.pre-commit\repodxm4yi\py_env\Scripts\activate: line 67: basename: command not found
bash: xargs: command not found
Activity
asottile commentedon Sep 2, 2014
Unfortunately I think windows support is pretty far from working due to the following things:
Minimal to run a python based hook:
xargs ... | ...for running hooksThe nice to haves that I don't know will work:
quentindemetz commentedon Sep 2, 2014
Understood ;(
asottile commentedon Jan 19, 2015
I started trying to get some of tests to pass here: https://github.com/pre-commit/pre-commit/tree/windoze
The first wall I'm hitting is symlinks, which require elevated privileges by default under windows (wtf).
I might rethink the one place I'm using symlinks and swap in something like sqlite instead (which might actually make everything simpler?).
For xargs, etc. I think I can depend on powershell (who would develop on windows without powershell amirite?). Here's some recipes I found from googling: http://five.agency/powershell-tips-for-bash-users/
asottile commentedon Jan 19, 2015
So I don't forget next time: pytest does not handle coloring well under powershell, use this in pytest.ini:
asottile commentedon Jan 19, 2015
Using git-shell (from github's windows downloads), I have pre-commit running! A bunch of the tests fail however and I'm not convinced that using github's tools constitutes supporting windows. But worst-case you can start using some of the hooks. I'm going to keep working on this branch and get more things passing.
bukzor commentedon Feb 5, 2015
I think it's fair to document git-shell as a dependency.
There's also MinGW, cygwin. I think git-shell is a customized mingw.
asottile commentedon Feb 27, 2015
Fixed via #196
@quentindemetz let me know if this works for you
asottile commentedon Feb 27, 2015
I've opened #198 #199 #200 #201 #202 for the features I didn't implement in the first pass.
quentindemetz commentedon Mar 8, 2015
@asottile git-shell is not supported on Windows XP, which is what I'm developing on…too bad
asottile commentedon Mar 8, 2015
What implementation of git are you using?
quentindemetz commentedon Mar 8, 2015
I think it's msysgit
This is the error I'm getting:
I don't know where to find the log mentioned in the last line:
Thanks
asottile commentedon Mar 8, 2015
I'm going to grab a VM and see if I can reproduce this.
~should be equivalent toC:\Documents and Settings\(your user name)on windowsasottile commentedon Mar 8, 2015
Ah I see the issue. Under Windows XP, msysgit's install doesn't provide an executable named
bash. I was however able to get this running and working with "git bash". Does what work for you?quentindemetz commentedon Mar 8, 2015
I in fact do have some version of bash installed (I think I also have git bash installed, I'm not quite sure how to tell which is which).
I've found the log, which isn't much more explanatory:
Running the command manually doesn't give many hints:
quentindemetz commentedon Mar 8, 2015
Looks like there is no py_env in the 'C:\Documents and Settings\IEUser.pre-commit\repoobvhtq' folder.
asottile commentedon Mar 8, 2015
Is that running with git bash as your shell or cmd as your shell?
quentindemetz commentedon Mar 8, 2015
With cmd.
Looks like it's working with git bash, (some hooks run, others don't, it's complaining about not finding the correct pep8 version, but that's another story).
Thanks ! Will use git bash from now on !
(for reference here is the pep8 issue I'm getting)
asottile commentedon Mar 8, 2015
Just fixed the pep8 conflict here: pre-commit/pre-commit-hooks@4078cbe
quentindemetz commentedon Mar 8, 2015
Fantastic, was just about to upgrade to the latest release of that repo, looks like I'll need to go as far as HEAD then. Thanks a million
asottile commentedon Mar 8, 2015
I'm releasing 0.4.1 right now :)
quentindemetz commentedon Mar 8, 2015
😍
guykisel commentedon Mar 9, 2015
This might be a stupid idea, but is it possible to embed bash in pre-commit to remove that dependency on windows?
asottile commentedon Mar 9, 2015
It'd be possible, but I'd rather not bundle all of msysgit when on windows I can expect most if not all of it to be installed :) (plus then I'd have to deal with the licensing issue)
guykisel commentedon Mar 9, 2015
I just want it to work in http://bliker.github.io/cmder/ on windows :(
(though it's possible it does actually work and I'm just doing something wrong)
When I try to use pre-commit in cmder I get this even though cmder supposedly has msysgit bundled in:
asottile commentedon Apr 16, 2016
@guykisel the latest version factors out bash and xargs so it should function better in cmder (0.8.0)
guykisel commentedon Apr 16, 2016
@asottile awesome! I'll give it a shot on Monday.