Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lstat /sh: no such file or directory #297

Open
shanduur opened this issue Nov 18, 2022 · 7 comments
Open

lstat /sh: no such file or directory #297

shanduur opened this issue Nov 18, 2022 · 7 comments
Assignees
Labels
question Further information is requested

Comments

@shanduur
Copy link

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.

@yoheimuta
Copy link
Owner

@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.

@yoheimuta yoheimuta added the question Further information is requested label Nov 19, 2022
@yoheimuta yoheimuta self-assigned this Nov 19, 2022
@shanduur
Copy link
Author

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.

@yoheimuta
Copy link
Owner

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.

@shanduur
Copy link
Author

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).

@yoheimuta
Copy link
Owner

@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?

@shanduur
Copy link
Author

Great! Thank you for your time, I will test that!

@yoheimuta
Copy link
Owner

yoheimuta commented Dec 19, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants