pre-commit-ci / issues

public issues for https://pre-commit.ci
17 stars 3 forks source link

error during build: CalledProcessError: command: ('/usr/bin/git', 'config', 'remote.origin.url') #30

Closed AleksaC closed 3 years ago

AleksaC commented 3 years ago

The error is caused by the hooks like this:

  - repo: local
    hooks:
      - id: go-imports
        name: Run goimports
        language: golang
        files: \.go$
        entry: goimports -w
        additional_dependencies: [golang.org/x/tools/cmd/goimports]

Here is the run with these hooks disabled. Here's the run with the hook above enabled. Since go vet works, the issue is probably with additional dependencies.


I also tested it locally using the following script, based on the one in https://github.com/pre-commit-ci/issues/issues/29#issuecomment-739325539

#!/bin/env bash
set -euxo pipefail
rm -rf advent-of-code-2020 pc
git clone git@github.com:aleksacu/advent-of-code-2020
mkdir pc
docker run \
    --user "$(id -u):$(id -g)" \
    --rm -ti \
    -v "$PWD/pc:/pc:rw" \
    -v "$PWD/advent-of-code-2020:/src:ro" \
    --workdir /src \
    ghcr.io/pre-commit-ci/runner-image \
    pre-commit install-hooks
docker run \
    --net=none \
    --user "$(id -u):$(id -g)" \
    --rm -ti \
    -v "$PWD/pc:/pc:ro" \
    -v "$PWD/advent-of-code-2020:/src:rw" \
    --workdir /src \
    ghcr.io/pre-commit-ci/runner-image \
    pre-commit run --all-files

However there is no error during the installation:

Status: Downloaded newer image for ghcr.io/pre-commit-ci/runner-image:latest
*[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/psf/black.
[INFO] Initializing environment for https://github.com/PyCQA/flake8.
[INFO] Initializing environment for local:golang.org/x/tools/cmd/goimports.
[INFO] Initializing environment for local:golang.org/x/lint/golint.
[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/psf/black.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/PyCQA/flake8.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for local.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for local.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
++ id -u
++ id -g
+ docker run --net=none --user 1000:1000 --rm -ti -v /home/aleksa/Desktop/temp/pc:/pc:ro -v /home/aleksa/Desktop/temp/advent-of-code-2020:/src:rw --workdir /src ghcr.io/pre-commit-ci/runner-image pre-commit run --all-files
Trim Trailing Whitespace.................................................Passed
Fix End of Files.........................................................Passed
Check Yaml...............................................................Passed
black....................................................................Passed
flake8...................................................................Passed
Run goimports............................................................Passed
Run go vet...............................................................Passed
Run go lint..............................................................Passed
Cargo fmt................................................................Failed
- hook id: rust-fmt
- exit code: 127

/src/scripts/pre-commit/cargo-fmt.sh: line 8: cargo: command not found

Cargo clippy.............................................................Failed
- hook id: clippy
- exit code: 127

./scripts/pre-commit/cargo-clippy.sh: line 8: cargo: command not found

Btw it seems that rust toolchain isn't part of the runner image. Is that intentional? Since there aren't already issues about that I see why adding it might have low priority.

asottile commented 3 years ago

hmm yeah looks like the blank local repo is missing the remote -- we clear the remote url for security reasons on the main repository but it shouldn't be cleared for the local repos -- I can get a fix for that

as for rust, it just hasn't been added yet -- you can submit a pull request at https://github.com/pre-commit-ci/runner-image

asottile commented 3 years ago

here's the difference between actual pre-commit: https://github.com/pre-commit/pre-commit/blob/92ce2dcbc375831bab244507e8072a834b761946/pre_commit/store.py#L208 -- I'll adjust pre-commit.ci to not undo this!

asottile commented 3 years ago

ok I've put in a patch to fix the remote issue, it will go out with the next image update! I'll update here once that is shipped

asottile commented 3 years ago

(note: that'll probably be monday as I'm waiting for a podman release)

AleksaC commented 3 years ago

Thanks for the quick response and fix! I'll try adding rust support to the image.

asottile commented 3 years ago

this should be deployed now -- thanks again for the issue!