-
Notifications
You must be signed in to change notification settings - Fork 269
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
Calling script without shebang results into "Exec format error" on alpine, but not on other linux distros or macos #404
Comments
the behaviour comes from busybox sh.
you could
i guess this is because busybox sh used another |
@fossdd thanks for your answer! Unfortunately, it didn't work for me with bash either. I started a container running Commands that I executed:
and then execute the commands above. I then tried to symlink /bin/sh to /bin/bash instead of /bin/busybox and it also didn't help. So it doesn't seem to be just a busybox issue. Also I tried to install busybox on debian and tried the same thing (using the same approach with sleep and exec) to execute commands from busybox and no error occured. Do you have any other ideas why it might happen? Or did I do anything wrong with this? |
oh, yeah. I didn't realized that you're using othewise the difference could maybe come from musl treating the function differently than glibc. but im no expert there. |
Thanks @fossdd! I did some additional investigations to verify your idea and got the following:
This makes me think it's likely to be alpine issue, not busybox one. I'm also not expert here, but hope someone manages to clarify this behavior |
The problem
Hello alpine maintainers! I wasn't sure which repo to report this problem, but decided to use this repo, since all we do is in docker.
Let me start with minimal example of the problem
The following code results into "env: can't execute './qwe': Exec format error", but only in alpine images (the one I used was 3.20.0).
I tested this code also on debian and on my macos and it outputs 1 and doesn't cause the error.
Why is it important?
This is a minimal example of reproducing a problem that we had with building react native app in docker container on our CI.
A similar situation happens when a script without shebang from react native build tools is called from java process in gradle. I'm not a linux expert, but I reduced this problem to the minimal example above, which works on MacOS (like the original react native build script), but doesn't work on alpine.
The part of build log looks like this
We investigated different reasons why it could happen (e.g., including architecture mismach), but in the end the minimal example above is what we came with. Since my understanding of the problem isn't deep enough, there is still a chance that these are 2 different problems, but I hope this background is helpful.
Questions
Is it possible to somehow make the example above work without adding shebang? E.g., by passing some env variable? Or by enabling some setting? I'm asking this in a hope that we might do the same in our build system so that we don't have to migrate from alpine to another distro. I'm going to report this problem to RN, since they might also update their scripts to add shebang and then it works, but it might take quite some time.
Can it be changed in alpine distro? And is it a bug or a normal behavior that can vary between distros?
Could you please explain why it happens like this in alpine, but not in other distros? I'm quite curios why it happens and it might be helpful for others.
The text was updated successfully, but these errors were encountered: