protolint
protolint copied to clipboard
lstat /sh: no such file or directory
While running yoheimuta/protolint:latest in GitLab CI, I am seeing the following issue:
Using docker image sha256:24c5a6b29f508becaf3a39e8c4cc52633d4f3b29e0c209841e3d280a6ba57094 for docker.io/yoheimuta/protolint:latest with digest yoheimuta/protolint@sha256:a5c141bd8c56c2282277da04e80c2842bc531f08cb84c009dac07d1fbf603d91 ...
lstat /sh: no such file or directory
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 2
I can't see why this is a issue, I switched to docker.io/library/golang:alpine and before script I installed it :
protolint:
before_script:
- go install github.com/yoheimuta/protolint/cmd/protolint@master
script:
- protolint lint ./proto/
only:
- main
- merge_requests
This works fine. There might be an issue with how the image is built.
@Shanduur docker build requires the protolint binary in your workplace.
I didn't expect that someone else wanted to build the protolint by themselves.
To use it as a tool, it's enough to run docker pull.
(base) ❯ docker pull yoheimuta/protolint:latest
latest: Pulling from yoheimuta/protolint
df9b9388f04a: Already exists
00f949594cdc: Pull complete
cb7e822d2ed3: Pull complete
Digest: sha256:a5c141bd8c56c2282277da04e80c2842bc531f08cb84c009dac07d1fbf603d91
Status: Downloaded newer image for yoheimuta/protolint:latest
docker.io/yoheimuta/protolint:latest
(base) ❯ docker run --volume "$(pwd):/workspace" --workdir /workspace yoheimuta/protolint version
protolint version 0.42.0(73ad453)
Let me know what you think.
No, no. I wanted to run the Protolint in the CI. Unfortunately, when using the docker image that you provided, the CI fails with the message I provided above:
lstat /sh: no such file or directory
When I use golang:alpine and install the protolint through go install ... it works fine.
Thank you for telling me.
I'm not familiar with GitLab CI.
Can you provide more specific information/instruction/steps to reproduce it on my hand?
I guess the excerpt of .gitlab-ci.yml seems helpful to narrow it down.
You fan create empty repository and add two files:
.gitlab-ci.yml:
protolint:
image: docker.io/yoheimuta/protolint:latest
script:
- protolint lint .
only:
- main
- merge_requests
example.proto:
syntax = "proto3";
package component_api;
message Component {
string name = 1;
uint32 status = 2;
}
message ComponentResponse {
Component component = 1;
string error = 3;
}
This would run on every commit to main branch and on every commit in open merge request (pull request).
@Shanduur I reproduced this issue. [1]
The immediate fix is resetting the entrypoint in .gitlab-ci.yml. [2]
protolint:
image:
name: docker.io/yoheimuta/protolint:latest
entrypoint: [""]
script:
- ls
- protolint lint .
only:
- main
- merge_requests
The root cause is that GitLab CI requires images to have sh or bash for Linux. [3]
And the protolint image has not installed any additional shell in an effort to keep it slim. [4]
To show this workaround for GitLab CI, I'm going to add a note at https://github.com/yoheimuta/protolint#ci-integration. What do you think?
- ref.
- [1] https://gitlab.com/yoheimuta/protolint_issue_297/-/jobs/3492039020
- [2] https://gitlab.com/yoheimuta/protolint_issue_297/-/jobs/3492312449
- [3] https://gitlab.com/gitlab-org/gitlab-runner/-/issues/26501
- [4] https://github.com/yoheimuta/protolint/blob/master/Dockerfile
Great! Thank you for your time, I will test that!
The root cause is that GitLab CI requires images to have sh or bash for Linux. [3] And the protolint image has not installed any additional shell in an effort to keep it slim. [4]
[memo] I found out that the image has /bin/sh.
(base) ❯ docker run -it --entrypoint /bin/ash yoheimuta/protolint
/ # /bin/sh -c "echo 1"
1
Consequently, I presume that running entrypoint by GitLab CI includes something unexpected as many users have reported similar experiences at https://gitlab.com/gitlab-org/gitlab-runner/-/issues/26501.