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

Docker language fails on Windows - os.getuid() #1072

Closed
cz-fish opened this issue Jul 3, 2019 · 1 comment · Fixed by #1094
Closed

Docker language fails on Windows - os.getuid() #1072

cz-fish opened this issue Jul 3, 2019 · 1 comment · Fixed by #1094

Comments

@cz-fish
Copy link

cz-fish commented Jul 3, 2019

docker_cmd in languages/docker.py uses os.getuid() and os.getgid() that don't exist in Python on Windows.

A hook that uses Docker on Windows fails to execute with

An unexpected error has occurred: AttributeError: module 'os' has no attribute 'getuid'
Traceback (most recent call last):
  File "C:\Python36\lib\site-packages\pre_commit\error_handler.py", line 46, in error_handler
    yield
  File "C:\Python36\lib\site-packages\pre_commit\main.py", line 294, in main
    return run(args.config, store, args)
  File "C:\Python36\lib\site-packages\pre_commit\commands\run.py", line 293, in run
    return _run_hooks(config, hooks, args, environ)
  File "C:\Python36\lib\site-packages\pre_commit\commands\run.py", line 214, in _run_hooks
    retval |= _run_single_hook(classifier, hook, args, skips, cols)
  File "C:\Python36\lib\site-packages\pre_commit\commands\run.py", line 124, in _run_single_hook
    tuple(filenames) if hook.pass_filenames else (),
  File "C:\Python36\lib\site-packages\pre_commit\repository.py", line 100, in run
    return lang.run_hook(self, file_args)
  File "C:\Python36\lib\site-packages\pre_commit\languages\docker.py", line 99, in run_hook
    cmd = docker_cmd() + entry_tag + cmd_rest
  File "C:\Python36\lib\site-packages\pre_commit\languages\docker.py", line 80, in docker_cmd
    '-u', '{}:{}'.format(os.getuid(), os.getgid()),
AttributeError: module 'os' has no attribute 'getuid'

The same hook works fine in Windows Subsystem for Linux.

@asottile
Copy link
Member

asottile commented Jul 3, 2019

makes sense, I haven't been able to get testing for docker on windows set up just yet -- not sure what the right thing to put for that argument is to be honest. The current support suggests only macos and linux for now

I'd be open to a patch if you'd like to get one working!

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

Successfully merging a pull request may close this issue.

2 participants