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

Git Beta: pre-commit does not initialize correctly #26297

Closed
WAKayser opened this issue Mar 7, 2025 · 3 comments
Closed

Git Beta: pre-commit does not initialize correctly #26297

WAKayser opened this issue Mar 7, 2025 · 3 comments
Labels
git Git integration feedback

Comments

@WAKayser
Copy link

WAKayser commented Mar 7, 2025

Summary

Initializing a venv for a pre-commit step fails.

Steps to trigger the problem:

  1. Create empty git repo
  2. install pre-commit: "uv tool install pre-commit"
  3. Add pre-commit config and simple python file.
  4. Install pre-commit hook with "pre-commit install"
  5. Optionally make sure caches are gone "pre-commit clean"
  6. Commit file.
repos:
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.9.10
    hooks:
      - id: ruff
      - id: ruff-format
print('hello world')

Actual Behavior:
The commit does not go through and gives the following error in
/Users/wouter/.cache/pre-commit/pre-commit.log

version information

pre-commit version: 4.1.0
git --version: git version 2.48.1
sys.version:
    3.12.6 (main, Sep  9 2024, 21:36:32) [Clang 18.1.8 ]
sys.executable: /Users/wouter/.local/share/uv/tools/pre-commit/bin/python3
os.name: posix
sys.platform: darwin

error information

An unexpected error has occurred: CalledProcessError: command: ('/opt/homebrew/bin/git', 'fetch', 'origin', '--tags')
return code: 128
stdout: (none)
stderr:
    git: 'remote-https' is not a git command. See 'git --help'.
    fatal: remote helper 'https' aborted session
Traceback (most recent call last):
  File "/Users/wouter/.local/share/uv/tools/pre-commit/lib/python3.12/site-packages/pre_commit/store.py", line 207, in clone_strategy
    self._shallow_clone(ref, _git_cmd)
  File "/Users/wouter/.local/share/uv/tools/pre-commit/lib/python3.12/site-packages/pre_commit/store.py", line 189, in _shallow_clone
    git_cmd('-c', git_config, 'fetch', 'origin', ref, '--depth=1')
  File "/Users/wouter/.local/share/uv/tools/pre-commit/lib/python3.12/site-packages/pre_commit/store.py", line 204, in _git_cmd
    cmd_output_b('git', *args, cwd=directory, env=env)
  File "/Users/wouter/.local/share/uv/tools/pre-commit/lib/python3.12/site-packages/pre_commit/util.py", line 111, in cmd_output_b
    raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/opt/homebrew/bin/git', '-c', 'protocol.version=2', 'fetch', 'origin', 'v0.9.10', '--depth=1')
return code: 128
stdout: (none)
stderr:
    git: 'remote-https' is not a git command. See 'git --help'.
    fatal: remote helper 'https' aborted session

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/wouter/.local/share/uv/tools/pre-commit/lib/python3.12/site-packages/pre_commit/error_handler.py", line 73, in error_handler
    yield
  File "/Users/wouter/.local/share/uv/tools/pre-commit/lib/python3.12/site-packages/pre_commit/main.py", line 389, in main
    return hook_impl(
           ^^^^^^^^^^
  File "/Users/wouter/.local/share/uv/tools/pre-commit/lib/python3.12/site-packages/pre_commit/commands/hook_impl.py", line 271, in hook_impl
    return retv | run(config, store, ns)
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wouter/.local/share/uv/tools/pre-commit/lib/python3.12/site-packages/pre_commit/commands/run.py", line 425, in run
    for hook in all_hooks(config, store)
                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wouter/.local/share/uv/tools/pre-commit/lib/python3.12/site-packages/pre_commit/repository.py", line 233, in all_hooks
    return tuple(
           ^^^^^^
  File "/Users/wouter/.local/share/uv/tools/pre-commit/lib/python3.12/site-packages/pre_commit/repository.py", line 236, in <genexpr>
    for hook in _repository_hooks(repo, store, root_config)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wouter/.local/share/uv/tools/pre-commit/lib/python3.12/site-packages/pre_commit/repository.py", line 211, in _repository_hooks
    return _cloned_repository_hooks(repo_config, store, root_config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wouter/.local/share/uv/tools/pre-commit/lib/python3.12/site-packages/pre_commit/repository.py", line 177, in _cloned_repository_hooks
    manifest_path = os.path.join(store.clone(repo, rev), C.MANIFEST_FILE)
                                 ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wouter/.local/share/uv/tools/pre-commit/lib/python3.12/site-packages/pre_commit/store.py", line 211, in clone
    return self._new_repo(repo, ref, deps, clone_strategy)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wouter/.local/share/uv/tools/pre-commit/lib/python3.12/site-packages/pre_commit/store.py", line 165, in _new_repo
    make_strategy(directory)
  File "/Users/wouter/.local/share/uv/tools/pre-commit/lib/python3.12/site-packages/pre_commit/store.py", line 209, in clone_strategy
    self._complete_clone(ref, _git_cmd)
  File "/Users/wouter/.local/share/uv/tools/pre-commit/lib/python3.12/site-packages/pre_commit/store.py", line 181, in _complete_clone
    git_cmd('fetch', 'origin', '--tags')
  File "/Users/wouter/.local/share/uv/tools/pre-commit/lib/python3.12/site-packages/pre_commit/store.py", line 204, in _git_cmd
    cmd_output_b('git', *args, cwd=directory, env=env)
  File "/Users/wouter/.local/share/uv/tools/pre-commit/lib/python3.12/site-packages/pre_commit/util.py", line 111, in cmd_output_b
    raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/opt/homebrew/bin/git', 'fetch', 'origin', '--tags')
return code: 128
stdout: (none)
stderr:
    git: 'remote-https' is not a git command. See 'git --help'.
    fatal: remote helper 'https' aborted session

Expected Behavior:
Install the environments correctly and run the checks.

Zed Version and System Specs

Zed: v0.177.4 (Zed Preview)
OS: macOS 15.3.1
Memory: 18 GiB
Architecture: aarch64

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

No applicable details in the log.

@WAKayser WAKayser added the git Git integration feedback label Mar 7, 2025
@cole-miller
Copy link
Contributor

An unexpected error has occurred: CalledProcessError: command: ('/opt/homebrew/bin/git', 'fetch', 'origin', '--tags')
stderr:
    git: 'remote-https' is not a git command. See 'git --help'.

Seems like you don't have the git-remote-https helper installed, or brew's git isn't finding it. Possibly this would be fixed by passing the right environment down to the commit command as in #26301. Does committing from the Zed terminal work?

@WAKayser
Copy link
Author

WAKayser commented Mar 7, 2025

Committing from the zed terminal works just fine.

@WAKayser
Copy link
Author

WAKayser commented Mar 7, 2025

I have just build the version from #26301, and the problem seems to be resolved. Thanks!

@WAKayser WAKayser closed this as completed Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
git Git integration feedback
Projects
None yet
Development

No branches or pull requests

2 participants