pre-commit → error: found a virtual manifest at `.../Cargo.toml` instead of a package manifest
Using typstyle in pre-commit configured with:
- repo: https://github.com/Enter-tainer/typstyle
rev: v0.12.12
hooks:
- id: typstyle
I got this error:
(venv) user@kinoite:~/git/sample_repo $ pre-commit clean
Cleaned /var/home/user/.cache/pre-commit.
(venv) user@kinoite:~/git/sample_repo $ pre-commit run --all-files
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/Enter-tainer/typstyle.
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/Enter-tainer/typstyle.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/var/home/user/.cache/pre-commit/repoqbaocqma/rustenv-default/bin/cargo', 'install', '--bins', '--root', '/var/home/user/.cache/pre-commit/repoqbaocqma/rustenv-default', '--path', '.')
return code: 101
stdout: (none)
stderr:
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2024-11-28, rust version 1.83.0 (90b35a623 2024-11-26)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'
error: found a virtual manifest at `/var/home/user/.cache/pre-commit/repoqbaocqma/Cargo.toml` instead of a package manifest
Check the log at /var/home/user/.cache/pre-commit/pre-commit.log
hi @34j does pre-commit works on your side recently?
It seems that pre-commit could not specify binaries in a workspace.
It requires cargo install --bins --path crates/typstyle, but pre-commit fixes the path as --path ..
https://github.com/pre-commit/pre-commit/issues/2931
seems that pre-commit doesn't think it's a bug. Any idea how to fix this?
As noted in the above issue, using Docker would be a workaround. Building and uploading Docker image to Docker Hub instead of just providing Dockerfile might be nicer in that users need not to build images locally (automatically) but is quite tedious. It would depend on your choice. (Unfortunately I cannot work with this right now due to personal issues sorry
Could we write a custom pre-commit-hook instead of using a rust preset? Just like ruff.
In my understanding pre-commit-ruff uses prebuilt binaries available on PyPI but does that apply to this project
For end users, this can be fixed by specifying additional_dependencies in a local hook:
- repo: local
hooks:
- id: typstyle
name: typstyle
description: Format files with typstyle
entry: typstyle
language: rust
types: [file]
additional_dependencies: ["cli:typstyle:0.12.14"]
files: \.typ$
args: [-i]
Should be resolved by the new action in #245
I think you are closing the wrong issue
I think you are closing the wrong issue
Did I misunderstand? I thought the problem could be avoided with the new action.
Not related because #245 is about GitHub Actions and this issue is about pre-commit. pre-commit is just a Git Hook like Husky (while pre-commit.ci is a GitHub app and pre-commit.ci lite is a GitHub action).
Are there an updates or officially recommended workarounds for this problem?
I'd like to use this project but the installation issues with pre-commit could be a show-stopper for me.
- repo: local hooks: - id: typstyle name: typstyle description: Format files with typstyle entry: typstyle language: rust types: [file] additional_dependencies: ["cli:typstyle:0.12.14"] files: \.typ$ args: [-i]
On second thought, I guess it would be better to create a new dedicated repository using the above config as a hook plus https://github.com/pre-commit/pre-commit-mirror-maker , which seems to have Rust support, to resolve this.
recommended workarounds
The above config should be a workaround
On second thought, I guess it would be better to create a new dedicated repository using the above config as a hook plus pre-commit/pre-commit-mirror-maker , which seems to have Rust support, to resolve this.
I made an attempt before (the pre-commit repo has been set private due to usability). But I found it awkward that typst users do NOT necessarily have a package manager available to provide the pre-compiled typstyle binary. That situation differs from other languages like JS, Python, or Rust. Thus, it comes to the conclusion that users have to prepare the binary themselves.
I don't think that is an issue since all the useres have to do is to install Rust. Can you make your repo public?
I see. Thanks!
@QuadnucYard I ran
uv tool install pre-commit-mirror-maker
git init pre-commit-typstyle
pre-commit-mirror pre-commit-typstyle --language=rust --package-name=typstyle --description="Format files with typstyle" --files-regex="\.typ$" --args="-i"
and added LICENSE README.md .github/workflows/main.yml (https://github.com/pre-commit/mirrors-mypy/blob/main/.github/workflows/main.yml with pre-commit-mirror ... replaced with the above command with pre-commit-typstyle replaced with .) and pushed them to https://github.com/34j/pre-commit-typstyle.
- repo: https://github.com/34j/pre-commit-typstyle
rev: "v0.13.18" # The the revision or tag you want to use
hooks:
- id: typstyle
It seems to be working correctly and I can transfer this repository to @typestyle-rs, or you may reproduce it yourself.
Works perfectly with https://pre-commit.ci, thanks a lot @34j 👌
hi @34j I saw your repo transfer request yesterday. It seems that the destination of transfer request you sent is my personal account. Is this due to permission issue? I guess I need add you to typstyle-rs first. If you’re can maintain pre-commit-typstyle in the future, I’m happy to accept the transfer request and add you to the typstyle-rs org. Let me know that you think!
@Enter-tainer There are two ways to do this: either add me to the organization (temporarily or permanently), or transfer it to you and then have you transfer it to the organization (in this case I would be an "outside collaborator", which might be better maybe?). Either way is fine.
Since I also need this feature, unless things change significantly, I am happy to put some effort into its maintenance.
Successfully transferred to https://github.com/typstyle-rs/pre-commit-typstyle:
- repo: https://github.com/typstyle-rs/pre-commit-typstyle
rev: "v0.13.18" # The the revision or tag you want to use
hooks:
- id: typstyle