-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Docker image >= 1.2.0 broken on M1 Mac? #11703
Comments
I can't reproduce this using the same command but with explicit version for the docker image ( This error means the compiler can't figure out the path of its executable, which on Linux is just resolving the symlink |
crystal build --static
broken in version >= 1.2.0?crystal build --static
broken in version >= 1.2.0? (Docker M1 Mac)
Hm, fwiw, I'm using Docker on a M1 Mac (but as seen above, docker runs Can consistently reproduce it here. Maybe it's indeed just a weird Docker-on-M1-Mac issue (wouldn't be the first). 🤔 |
Can't reproduce in an Intel Mac (macOS 11.6.2) |
crystal build --static
broken in version >= 1.2.0? (Docker M1 Mac)
Someone on a M1 Mac I should add. (but thanks nonetheless! 🙂) Some new findings (also updated the description above accordingly):
|
To investigate further: Using the working 1.1.1 image, you could build a dev version of the compiler with some strategic The base image has actually been downgraded from alpine:3.13 to alpine:3.12 between 1.1.1 and 1.2.2 (crystal-lang/distribution-scripts#127). |
After some more dabbling I'm afraid that may not provide further insight.
The 1.1.1 binary works fine in both containers. The bug seems to be in the crystal-binary, so a dev-version tldr, it looks like:
Unfortunately don't have time to dig deeper into this atm Would also be inclined to suggest that nobody else (don't want to send you down rabbit holes and in the end it turns |
Just want to chime in here - I'm on an M1 Mac trying to build a dev version of the compiler and I'm running into this same error. I'm coming at this somewhat laterally, so apologies if I'm jumping in at the wrong point. But I'm running Docker Desktop 4.3.2 (72729) on an M1 MacBook Pro (2021). Grabbed the 1.3.0-dev-build docker image, the latest source, and tried running simply
|
Any progress on it? I don't know why but it works fine :
Also there are aarch64 images available and they work faster on M1 amd64:
arm64:
|
@alexkutsan That's because anything other than |
I'm seeing the same problem in an amd64 Debian Bullseye systemd container running on an ARM64 board running Armbian. I see the problem with crystal 1.3 and 1.2 but crystal 1.1 works. It's probably unrelated to Docker since I don't use it. It might be related to qemu though. |
Same problem with crystal 1.4. However, copying the following files from the x86_64 Debian bullseye docker image from https://github.com/84codes/crystal-container-images (thanks @alexkutsan]) in my x86_64 container worked:
I suppose directly using the arm64 version in a native container or in the main system would work too. Could it be that the ORIGIN / CRYSTAL_CONFIG_PATH values are somehow incorrect? It seems like the error is coming from
The difference I can see between running crystal natively and in qemu is that the |
I don't know why, but building my docker image (multistage build, on Apple M1 Max chip) with latest docker hub crystal (tagged "crystallang/crystal:latest") ending with this error:
And building with docker hub image from "84codes" (tagged 84codes/crystal:latest-ubuntu-22.04) ending with result OK. My
Difference is only with this line Build command is: $ docker buildx build --platform linux/amd64 -t sample/base-ruby-image . |
Just read through this issue and can confirm that this issue affects both the alpine & non-alpine builds (M1 mac, Docker version 20.10.16).
Same issue on crystal 1.4.1. Where can the Dockerfiles used to generate docker hub images be found (in case these contain a clue)? |
Thanks for looking into it @mloughran , here are the docker files. |
Been running into this, too. Looks like it happens here, which looks to be caused by It works fine on my M1 without Docker, so maybe since this involves a system call, this bug could be specific to the combination of arm64+linux, and not necessarily Docker+M1? |
I'd like to help with this issue. Crystal arm64 m1 builds from macports work beautifully, the issues I have are during docker image build, ending with the same message as this issue. To build my own arm64 linux crystal image, should I try to use as the base these Dockerfiles and Makefile https://github.com/crystal-lang/distribution-scripts/tree/master/docker I don't know what's their respective purposes. It looks to me like the first one is meant to built the crystallang/crystal docker images, and the second is using docker only to isolate the build process from the rest of the system? Or is the crystallang/crystal image built some different way? |
Exactly. |
Ok. So I wanted to try building crystal using the All these builds use default docker platform, i.e. arm64/v8 on the M1 mac. Building with
-EDIT: Is this the same issue as #8738?- EDIT2: this crashed on non-musl build, so nevermind. Shards are using musl, though... and that's amd64, this occured during arm64/v8 build.
I see the build is failing because it tries to build arm64 (aarch64) vs x86_64 targets and gets confused. So I tried different strategy - use docker multiarch build to build amd64 binaries. After patching diff --git a/linux/Makefile b/linux/Makefile
index d055d5b..bb03911 100644
--- a/linux/Makefile
+++ b/linux/Makefile
@@ -77,7 +77,7 @@ build: $(OUTPUT_BASENAME64).tar ## Build the raw uncompressed tarball
$(OUTPUT_BASENAME64).tar: Dockerfile
mkdir -p $(OUTPUT_DIR)
- docker build $(BUILD_ARGS64) -t crystal-build-temp .
+ docker buildx build --platform linux/amd64 $(BUILD_ARGS64) -t crystal-build-temp .
container_id="$$(docker create crystal-build-temp)" \
&& docker cp "$$container_id":/output/crystal-$(CRYSTAL_VERSION)-$(PACKAGE_ITERATION).tar $@ \
&& docker rm -v "$$container_id"
@@ -93,7 +93,7 @@ $(OUTPUT_BASENAME64)-bundled: $(OUTPUT_BASENAME64).tar $(OUTPUT_DIR)/bundled-lib
$(OUTPUT_DIR)/bundled-libs.tar: bundled.dockerfile
mkdir -p $(OUTPUT_DIR)
- docker build $(BUILD_ARGS64_BUNDLED) -t crystal-build-temp -f bundled.dockerfile .
+ docker buildx build --platform linux/amd64 $(BUILD_ARGS64_BUNDLED) -t crystal-build-temp -f bundled.dockerfile .
container_id="$$(docker create crystal-build-temp)" \
&& docker cp "$$container_id":/output/bundled-libs.tar $@ \
&& docker rm -v "$$container_id" both versions 1.0.0 and 1.1.1 successfuly compile Failure during the shards build:
I don't understand why crystal compiled and shards doesn't. |
Yes, it basically works the same way as on any other platform. There is currently no recipe for this in distribution-scripts, though.
We're planning to use CI for building aarch64 distribution packages, but it's not yet implemented. You can use the docker images provided by 84codes: https://hub.docker.com/r/84codes/crystal Any version since 1.0.0 should work for The error messages are weird. Might be running out of memory? |
The docker desktop VM has 8 GB limit currently and no other containers are running. I can try to increase the limit. The errors are probably caused by the use of QEMU, since these are the amd64 build variants. So maybe it can be a clue, even if the error message is completely different? |
It seems to be a known bug in qemu. See docker/for-mac#6049 for some pointers. There doesn't seem to be any fix planned for the time being 😭 Given this is crashing the compiler, maybe we'd like to have a hardcoded fallback in |
(this comment can be ignored, was user error)It seems the 84codes images also no longer work. :(
(doesn't matter which of their images I try, all the binaries in them give me this error) |
@m-o-e please try |
@carlhoerberg Uargh, yes, this works. Thanks. 🙈 |
Just noticed this issue is still open. I think we can close it, since Docker Desktop officially supports Rosetta 2, which isn't experimental anymore. I think it's even enabled by default? https://www.docker.com/blog/docker-desktop-4-25/ says it is:
I had enabled "the Rosetta checkbox" in Docker Desktop for over a year and a half now and I haven't encountered any issues. EDIT: docker/roadmap#384 shows people are still having some issues when using Rosetta in Docker Desktop, but that shouldn't be Crystal's concern, in my opinion. |
Bug Report
Trying to
build
in docker withlatest-alpine
,nightly-alpine
or
v1.2.*-alpine
gives me the following error:Building with
v1.1.1-alpine
works fine.The text was updated successfully, but these errors were encountered: