Skip to content
This repository has been archived by the owner on Dec 17, 2022. It is now read-only.

Unable to use checkmake hook #2

Closed
colindean opened this issue Apr 26, 2022 · 6 comments
Closed

Unable to use checkmake hook #2

colindean opened this issue Apr 26, 2022 · 6 comments

Comments

@colindean
Copy link
Contributor

I've placed this in my pre-commit configuration:

  - repo: https://github.com/Lucas-C/pre-commit-hooks-go
    rev: v1.0.1
    hooks:
      - id: checkmake

It errors when setting up.

pre-commit log output:

version information

pre-commit version: 2.18.1
git --version: git version 2.36.0
sys.version:
    3.10.2 (main, Feb  2 2022, 05:51:25) [Clang 13.0.0 (clang-1300.0.29.3)]
sys.executable: /opt/homebrew/Cellar/pre-commit/2.18.1/libexec/bin/python3
os.name: posix
sys.platform: darwin

error information

An unexpected error has occurred: CalledProcessError: command: ('/opt/homebrew/bin/go', 'install', './...')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    pattern ./...: directory prefix . does not contain main module or its selected dependencies
    
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/pre-commit/2.18.1/libexec/lib/python3.10/site-packages/pre_commit/error_handler.py", line 73, in error_handler
    yield
  File "/opt/homebrew/Cellar/pre-commit/2.18.1/libexec/lib/python3.10/site-packages/pre_commit/main.py", line 343, in main
    return hook_impl(
  File "/opt/homebrew/Cellar/pre-commit/2.18.1/libexec/lib/python3.10/site-packages/pre_commit/commands/hook_impl.py", line 237, in hook_impl
    return retv | run(config, store, ns)
  File "/opt/homebrew/Cellar/pre-commit/2.18.1/libexec/lib/python3.10/site-packages/pre_commit/commands/run.py", line 414, in run
    install_hook_envs(to_install, store)
  File "/opt/homebrew/Cellar/pre-commit/2.18.1/libexec/lib/python3.10/site-packages/pre_commit/repository.py", line 221, in install_hook_envs
    _hook_install(hook)
  File "/opt/homebrew/Cellar/pre-commit/2.18.1/libexec/lib/python3.10/site-packages/pre_commit/repository.py", line 79, in _hook_install
    lang.install_environment(
  File "/opt/homebrew/Cellar/pre-commit/2.18.1/libexec/lib/python3.10/site-packages/pre_commit/languages/golang.py", line 83, in install_environment
    cmd_output_b('go', 'install', './...', cwd=repo_src_dir, env=env)
  File "/opt/homebrew/Cellar/pre-commit/2.18.1/libexec/lib/python3.10/site-packages/pre_commit/util.py", line 146, in cmd_output_b
    raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/opt/homebrew/bin/go', 'install', './...')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    pattern ./...: directory prefix . does not contain main module or its selected dependencies

I speculate that this might be a pre-commit problem and not this specific checkmake hook's problem. It seems like how pre-commit is invoking go install may be nonsensical.

@trinitronx
Copy link

Looks like the ./... ellipsis syntax for the go install command is valid, and is just a wildcard for a variable number of packages found in the current directory.

Perhaps the underlying issue is that this hook has not been updated since Nov 2019, while the upstream dependency on mrtazz/checkmake has been updated since then to support newer versions of Golang?

@trinitronx
Copy link

@colindean, @Lucas-C: Looks like some things have changed with Go modules and the upstream mrtazz/checkmake project.
I've tried to get this working on my fork trinitronx/pre-commit-hooks-go@testing-checkmake-update but without success thanks to go mod tidy expecting the upstream package github.com/mrtazz/checkmake to match the git repo path. It uses package main, so we cannot include it as a wrapper.

Trying with simply additional_dependencies: [github.com/mrtazz/checkmake] in the .pre-commit-hooks.yaml definition also fails with the same go install ./... error as before.

So it looks like the assumptions made by new versions of GoLang and Go modules are preventing this repo from wrapping the upstream Go project as a pre-commit hook. The way pre-commit hooks for language: golang are designed, we will need to include the pre-commit hook in the upstream project unless it's actually a library (e.g. no package main).

I've opened a Pull Request upstream to get this included in that repo:
mrtazz/checkmake#69

@Lucas-C
Copy link
Owner

Lucas-C commented Apr 29, 2022

@colindean, @trinitronx : thank you both for investigating this.

I'm not using this pre-commit hook anymore, and I'd be happy if it gets integrated in mrtazz/checkmake.

Else, if you find a way to make it works in a PR, I'll be happy to merge it.

@richtong
Copy link

Any update on this, I see the PR submitted by @trinitronx but it hasn't been accepted :-)

@Lucas-C
Copy link
Owner

Lucas-C commented Jun 15, 2022

Alright, but nobody here can do much about it 😊

You were right to add a comment on mrtazz/checkmake#69, that's probably where things can move forward

@colindean
Copy link
Contributor Author

mrtazz/checkmake#69 was merged, so I consider this done!

@Lucas-C, perhaps you could/should commit to the README pointing people to checkmake directly and archive this repo…?

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

No branches or pull requests

4 participants