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

pre-commit hooks having execution problems on solaris (smartos) #2389

Closed
gaige opened this issue May 13, 2022 · 8 comments · Fixed by #2390
Closed

pre-commit hooks having execution problems on solaris (smartos) #2389

gaige opened this issue May 13, 2022 · 8 comments · Fixed by #2390

Comments

@gaige
Copy link
Contributor

gaige commented May 13, 2022

search tried in the issue tracker

solaris

describe your issue

After using pre-commit on my local workstation for some time, I installed (using pip) on my SmartOS system (Solaris derivative). Install went fine, and execution without changed files (pre-commit run) executed without problems.

As soon as I have a file to commit, or I run pre-commit run -a, pre-commit fails with:

termios.error: (22, 'Invalid argument')

The backtrace is:

Traceback (most recent call last):
  File "/opt/local/lib/python3.9/site-packages/pre_commit/error_handler.py", line 73, in error_handler
    yield
  File "/opt/local/lib/python3.9/site-packages/pre_commit/main.py", line 389, in main
    return run(args.config, store, args)
  File "/opt/local/lib/python3.9/site-packages/pre_commit/commands/run.py", line 416, in run
    return _run_hooks(config, hooks, skips, args)
  File "/opt/local/lib/python3.9/site-packages/pre_commit/commands/run.py", line 285, in _run_hooks
    current_retval, prior_diff = _run_single_hook(
  File "/opt/local/lib/python3.9/site-packages/pre_commit/commands/run.py", line 192, in _run_single_hook
    retcode, out = language.run_hook(hook, filenames, use_color)
  File "/opt/local/lib/python3.9/site-packages/pre_commit/languages/python.py", line 230, in run_hook
    return helpers.run_xargs(hook, hook.cmd, file_args, color=color)
  File "/opt/local/lib/python3.9/site-packages/pre_commit/languages/helpers.py", line 137, in run_xargs
    return xargs(cmd, file_args, **kwargs)
  File "/opt/local/lib/python3.9/site-packages/pre_commit/xargs.py", line 164, in xargs
    for proc_retcode, proc_out, _ in results:
  File "/opt/local/lib/python3.9/concurrent/futures/_base.py", line 609, in result_iterator
    yield fs.pop().result()
  File "/opt/local/lib/python3.9/concurrent/futures/_base.py", line 446, in result
    return self.__get_result()
  File "/opt/local/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
    raise self._exception
  File "/opt/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/opt/local/lib/python3.9/site-packages/pre_commit/xargs.py", line 156, in run_cmd_partition
    return cmd_fn(
  File "/opt/local/lib/python3.9/site-packages/pre_commit/util.py", line 211, in cmd_output_p
    with open(os.devnull) as devnull, Pty() as pty:
  File "/opt/local/lib/python3.9/site-packages/pre_commit/util.py", line 171, in __enter__
    attrs = termios.tcgetattr(self.r)

pre-commit --version

pre-commit 2.19.0

.pre-commit-config.yaml

# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.2.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
        exclude: ^group_vars/|^host_vars
      - id: check-added-large-files
      - id: check-json
  - repo: https://github.com/executablebooks/mdformat
    rev: 0.7.14  # Use the ref you want to point at
    hooks:
      - id: mdformat
        # optional
        additional_dependencies:
          - mdformat-tables
          - mdformat-black
  - repo: https://github.com/ansible-community/ansible-lint
    rev: v6.0.2 # Use the ref you want to point at
    hooks:
      - id: ansible-lint

~/.cache/pre-commit/pre-commit.log (if present)

version information

pre-commit version: 2.19.0
git --version: git version 2.36.0
sys.version:
    3.9.12 (main, May  9 2022, 22:49:33) 
    [GCC 10.3.0]
sys.executable: /opt/local/bin/python3.9
os.name: posix
sys.platform: sunos5

error information

An unexpected error has occurred: error: (22, 'Invalid argument')
Traceback (most recent call last):
  File "/opt/local/lib/python3.9/site-packages/pre_commit/error_handler.py", line 73, in error_handler
    yield
  File "/opt/local/lib/python3.9/site-packages/pre_commit/main.py", line 389, in main
    return run(args.config, store, args)
  File "/opt/local/lib/python3.9/site-packages/pre_commit/commands/run.py", line 416, in run
    return _run_hooks(config, hooks, skips, args)
  File "/opt/local/lib/python3.9/site-packages/pre_commit/commands/run.py", line 285, in _run_hooks
    current_retval, prior_diff = _run_single_hook(
  File "/opt/local/lib/python3.9/site-packages/pre_commit/commands/run.py", line 192, in _run_single_hook
    retcode, out = language.run_hook(hook, filenames, use_color)
  File "/opt/local/lib/python3.9/site-packages/pre_commit/languages/python.py", line 230, in run_hook
    return helpers.run_xargs(hook, hook.cmd, file_args, color=color)
  File "/opt/local/lib/python3.9/site-packages/pre_commit/languages/helpers.py", line 137, in run_xargs
    return xargs(cmd, file_args, **kwargs)
  File "/opt/local/lib/python3.9/site-packages/pre_commit/xargs.py", line 164, in xargs
    for proc_retcode, proc_out, _ in results:
  File "/opt/local/lib/python3.9/concurrent/futures/_base.py", line 609, in result_iterator
    yield fs.pop().result()
  File "/opt/local/lib/python3.9/concurrent/futures/_base.py", line 446, in result
    return self.__get_result()
  File "/opt/local/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
    raise self._exception
  File "/opt/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/opt/local/lib/python3.9/site-packages/pre_commit/xargs.py", line 156, in run_cmd_partition
    return cmd_fn(
  File "/opt/local/lib/python3.9/site-packages/pre_commit/util.py", line 211, in cmd_output_p
    with open(os.devnull) as devnull, Pty() as pty:
  File "/opt/local/lib/python3.9/site-packages/pre_commit/util.py", line 171, in __enter__
    attrs = termios.tcgetattr(self.r)
termios.error: (22, 'Invalid argument')
@gaige
Copy link
Contributor Author

gaige commented May 13, 2022

There are similar problems with other projects and calling termios.tcgetattr() on the "master" fd for a pty pair:

@asottile
Copy link
Member

does changing r to w work on your platform and does it still produce color for underlying tools? (you can try pre-commit run mypy --all-files in this repository)

@asottile
Copy link
Member

solaris isn't supported by cpython either so it's likely support will be "at your best effort" -- afaik you're the only person who has ever tried running on solaris

@asottile
Copy link
Member

you can likely work around using export PRE_COMMIT_COLOR=never

@gaige
Copy link
Contributor Author

gaige commented May 13, 2022

I was in the process of checking the r/w switch. I'll let you know (took some time to get a clean environment set up for testing).

@gaige
Copy link
Contributor Author

gaige commented May 13, 2022

Good call on the PRE_COMMIT_COLOR=never, that does suppress the problem (and the color). Working on the r/w switch now.

@gaige
Copy link
Contributor Author

gaige commented May 13, 2022

As for the cpython issue... yeah, I'm familiar with it. I have been trying to get the team there to let me provide an automated test environment. In the interim, I've provided some PRs in the past for Solaris-specific issues.

@gaige
Copy link
Contributor Author

gaige commented May 13, 2022

Swapping r and w does fix under solaris. I'll check with a couple of other environments to see what will be a compatible change.

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

Successfully merging a pull request may close this issue.

2 participants