lychee icon indicating copy to clipboard operation
lychee copied to clipboard

problems with lychee pre-commit installation

Open dpinol opened this issue 10 months ago • 8 comments

  1. With the following pre-commit configuration as per the README.md, running "pre-commit run --all lychee" fails with error "Executable lychee not found". I had to cd into the pre-commit environment and manually run "make install".
  - repo: https://github.com/lycheeverse/lychee.git
    rev: v0.15.1
    hooks:
      - id: lychee
        # Optionally include additional CLI arguments
        args: ["--no-progress", "--exclude", "file://"]
  1. Above v0.15.1, the rev pre-commit field must have the syntax "lychee-v0.1X.X". Is this intended? All pre-commit hooks I've seen have revisions with format "v9.9.9"

thanks

dpinol avatar Feb 17 '25 15:02 dpinol

It looks like there are two distinct issues being reported:

  1. Pre-commit hook installation failure The error "Executable lychee not found" suggests the pre-commit hook isn't properly installing the lychee binary. Having to manually cd into the pre-commit environment and run "make install" shouldn't be necessary. This likely indicates an issue with the hook's installation script.

Have you tried any of these steps?

  • Clearing your pre-commit cache: pre-commit clean
  • Updating pre-commit: pre-commit autoupdate
  1. Version tag format change The prefix was automatically added when we switched to release-plz. I'm not too happy with that change, as it caused many problems. At the moment, I wouldn't want to switch back to non-prefixed releases as I know it will break a lot of things again. Sorry about that.

Does that mean you changed the above version string from rev: v0.15.1 to rev: lychee-v0.15.1? If not, you can try adapting your pre-commit config like this to see if it works out of the box:

- repo: https://github.com/lycheeverse/lychee.git
  rev: lychee-v0.18.1  # If using newer versions
  hooks:
    - id: lychee
      args: ["--no-progress", "--exclude", "file://"]

(You probably have to re-install the hook.)

Would you be able to provide:

  1. Your operating system details
  2. The output of pre-commit --version

This would help us identify if this is a broader issue that needs to be addressed in the documentation or codebase.

mre avatar Feb 18 '25 17:02 mre

Also, I wonder if someone else got it to work? If there's anyone reading this who uses the pre-commit configuration, please add a comment.

mre avatar Feb 18 '25 17:02 mre

Also, I wonder if someone else got it to work? If there's anyone reading this who uses the pre-commit configuration, please add a comment.

Hi I am facing the same issue as well.

Image

pre-commit configuration:

repos:
  - repo: https://github.com/lycheeverse/lychee.git
    rev: lychee-v0.18.1
    hooks:
      - id: lychee
        args: ["--no-progress", "."]
        pass_filenames: false

Information:

Operating system: macOS Sequoia (Version 15.3) Pre-commit version: pre-commit 4.1.0

lyndonlim27 avatar Mar 18 '25 07:03 lyndonlim27

Thanks. Does it work if you change it to this?

repos:
  - repo: https://github.com/lycheeverse/lychee.git
    rev: lychee-bin-v0.18.1
    hooks:
      - id: lychee
        args: ["--no-progress", "."]
        pass_filenames: false

mre avatar Mar 19 '25 15:03 mre

With lychee-bin-v0.18.1

pre-commit run --all lychee
[INFO] Initializing environment for https://github.com/lycheeverse/lychee.git.
An unexpected error has occurred: CalledProcessError: command: ('/usr/bin/git', 'checkout', 'lychee-bin-v0.18.1')
return code: 1
stdout: (none)
stderr:
    error: pathspec 'lychee-bin-v0.18.1' did not match any file(s) known to git
Check the log at /home/dani/.cache/pre-commit/pre-commit.log

With lychee-v0.18.1

pre-commit run --all lychee
[INFO] Initializing environment for https://github.com/lycheeverse/lychee.git.
lychee...................................................................Failed
- hook id: lychee
- exit code: 1

Executable `lychee` not found

dpinol avatar Mar 19 '25 16:03 dpinol

With lychee-bin-v0.18.1

pre-commit run --all lychee
[INFO] Initializing environment for https://github.com/lycheeverse/lychee.git.
An unexpected error has occurred: CalledProcessError: command: ('/usr/bin/git', 'checkout', 'lychee-bin-v0.18.1')
return code: 1
stdout: (none)
stderr:
    error: pathspec 'lychee-bin-v0.18.1' did not match any file(s) known to git
Check the log at /home/dani/.cache/pre-commit/pre-commit.log

With lychee-v0.18.1

pre-commit run --all lychee
[INFO] Initializing environment for https://github.com/lycheeverse/lychee.git.
lychee...................................................................Failed
- hook id: lychee
- exit code: 1

Executable `lychee` not found

I face the same exact error as you too

lyndonlim27 avatar Mar 20 '25 07:03 lyndonlim27

Clearly I don't know how pre-commit hooks, but has anyone tried this?

- repo: https://github.com/lycheeverse/lychee.git
  rev: lychee-v0.18.1
  hooks:
    - id: lychee-bin

mre avatar Mar 21 '25 08:03 mre

It doesn't work either

(sc-api) ➜  sc-api git:(regression-forest-no-logger) ✗ pre-commit run --all lychee-bin
[INFO] Initializing environment for https://github.com/lycheeverse/lychee.git.
An unexpected error has occurred: CalledProcessError: command: ('/usr/bin/git', 'checkout', 'lychee-bin-v0.18.1')
return code: 1
stdout: (none)
stderr:
    error: pathspec 'lychee-bin-v0.18.1' did not match any file(s) known to git
Check the log at /home/dani/.cache/pre-commit/pre-commit.log

I think the problem is that lychee's yaml specifies system, which requires the binary to be compiled.

Maybe you can get inspiration from ruff config, which is also developed in rust https://github.com/astral-sh/ruff-pre-commit/blob/main/.pre-commit-hooks.yaml

Btw, pre-commit run lychee-docker does work

dpinol avatar Mar 21 '25 09:03 dpinol

I took a stab at it in #1829.

The main problem is that precommit-hooks don't work well with Rust workspaces yet, as far as I can see. The workaround is a custom script which triggers the installation process on-demand. I made a small optimization to use cargo binstall if it's available. This could speed up the installation process a bit. We fall back on cargo install.

Does that work for all of you? I would appreciate any feedback on this approach.

mre avatar Aug 29 '25 17:08 mre

I merged the PR, which hopefully fixes the issue. Nevertheless, I'd still like to get some feedback here, so in case someone reads this, please post a comment if you tried it, and it works / doesn't work for you. 🙏

mre avatar Sep 01 '25 15:09 mre

Seems to work as reported in https://github.com/lycheeverse/lychee/pull/1829#issuecomment-3244464383. Closing. 😃

mre avatar Sep 04 '25 10:09 mre

Hi, any plans to make a release with this soon?

thanks

acabal33uab avatar Oct 02 '25 14:10 acabal33uab