Cross-platform specific error when installing latest hex

It seems like downloading latest hex when building for a non-native platform is broken :thinking:

I have the following Dockerfile:

FROM hexpm/elixir:1.16.2-erlang-26.2.3-alpine-3.19.1
RUN apk add git
RUN mix archive.install github hexpm/hex branch latest --force

Using M-series MacBook if I build it for amd64 architecture, I get an error:

docker buildx build --platform linux/amd64 --file ./Dockerfile --no-cache --progress plain .
# ...
3.067 ==> hex
3.069 Error while loading project :"new package" at /tmp/mix-local-installer-fetcher-3T_JSQ/deps/new package
3.080 ** (ArgumentError) could not call Module.put_attribute/3 because the module Hex.MixProject is already compiled
3.080     (elixir 1.16.2) lib/module.ex:2360: Module.assert_not_readonly!/2
3.080     (elixir 1.16.2) lib/module.ex:2041: Module.__put_attribute__/5
3.080     /tmp/mix-local-installer-fetcher-3T_JSQ/deps/new package/mix.exs:172: (module)
3.080     (stdlib 5.2.1) lists.erl:1599: :lists.foldl_1/3
Full output
#0 building with "mybuilder" instance using docker-container driver

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 171B done
#1 DONE 0.0s

#2 [internal] load metadata for docker.io/hexpm/elixir:1.16.2-erlang-26.2.3-alpine-3.19.1
#2 DONE 0.4s

#3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s

#4 [1/3] FROM docker.io/hexpm/elixir:1.16.2-erlang-26.2.3-alpine-3.19.1@sha256:aed90d87c95d2cb41b2fc589b781ceca11d5faf6e533b89587e741943274a4e7
#4 resolve docker.io/hexpm/elixir:1.16.2-erlang-26.2.3-alpine-3.19.1@sha256:aed90d87c95d2cb41b2fc589b781ceca11d5faf6e533b89587e741943274a4e7 done
#4 CACHED

#5 [2/3] RUN apk add git
#5 0.046 fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/main/x86_64/APKINDEX.tar.gz
#5 0.240 fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/community/x86_64/APKINDEX.tar.gz
#5 0.428 (1/9) Installing brotli-libs (1.1.0-r1)
#5 0.455 (2/9) Installing c-ares (1.27.0-r0)
#5 0.474 (3/9) Installing libunistring (1.1-r2)
#5 0.503 (4/9) Installing libidn2 (2.3.4-r4)
#5 0.523 (5/9) Installing nghttp2-libs (1.58.0-r0)
#5 0.545 (6/9) Installing libcurl (8.5.0-r0)
#5 0.570 (7/9) Installing libexpat (2.6.2-r0)
#5 0.593 (8/9) Installing pcre2 (10.42-r2)
#5 0.619 (9/9) Installing git (2.43.0-r0)
#5 0.690 Executing busybox-1.36.1-r15.trigger
#5 0.699 OK: 24 MiB in 35 packages
#5 DONE 0.7s

#6 [3/3] RUN mix archive.install github hexpm/hex branch latest --force
#6 0.720 * Getting new package (https://github.com/hexpm/hex.git - origin/latest)
#6 1.340 remote: Enumerating objects: 13806, done.
remote: Counting objects: 100% (1261/1261), done.
remote: Compressing objects: 100% (661/661), done.
#6 1.756 remote: Total 13806 (delta 757), reused 966 (delta 542), pack-reused 12545
#6 2.124 ==> hex
#6 2.125 Error while loading project :"new package" at /tmp/mix-local-installer-fetcher-jW0twA/deps/new package
#6 2.141 ** (ArgumentError) could not call Module.put_attribute/3 because the module Hex.MixProject is already compiled
#6 2.141     (elixir 1.16.2) lib/module.ex:2360: Module.assert_not_readonly!/2
#6 2.141     (elixir 1.16.2) lib/module.ex:2041: Module.__put_attribute__/5
#6 2.141     /tmp/mix-local-installer-fetcher-jW0twA/deps/new package/mix.exs:172: (module)
#6 2.141     (stdlib 5.2.1) lists.erl:1599: :lists.foldl_1/3
#6 ERROR: process "/bin/sh -c mix archive.install github hexpm/hex branch latest --force" did not complete successfully: exit code: 1
------
 > [3/3] RUN mix archive.install github hexpm/hex branch latest --force:
remote: Counting objects: 100% (1261/1261), done.
remote: Compressing objects: 100% (661/661), done.
1.756 remote: Total 13806 (delta 757), reused 966 (delta 542), pack-reused 12545
2.124 ==> hex
2.125 Error while loading project :"new package" at /tmp/mix-local-installer-fetcher-jW0twA/deps/new package
2.141 ** (ArgumentError) could not call Module.put_attribute/3 because the module Hex.MixProject is already compiled
2.141     (elixir 1.16.2) lib/module.ex:2360: Module.assert_not_readonly!/2
2.141     (elixir 1.16.2) lib/module.ex:2041: Module.__put_attribute__/5
2.141     /tmp/mix-local-installer-fetcher-jW0twA/deps/new package/mix.exs:172: (module)
2.141     (stdlib 5.2.1) lists.erl:1599: :lists.foldl_1/3
------
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
Dockerfile:3
--------------------
   1 |     FROM hexpm/elixir:1.16.2-erlang-26.2.3-alpine-3.19.1
   2 |     RUN apk add git
   3 | >>> RUN mix archive.install github hexpm/hex branch latest --force
   4 |
--------------------
ERROR: failed to solve: process "/bin/sh -c mix archive.install github hexpm/hex branch latest --force" did not complete successfully: exit code: 1
docker system info
docker system info
Client:
 Version:    25.0.5
 Context:    orbstack
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.13.1
    Path:     /Users/eugene/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.24.5
    Path:     /Users/eugene/.docker/cli-plugins/docker-compose

Server:
 Containers: 46
  Running: 11
  Paused: 0
  Stopped: 35
 Images: 94
 Server Version: 25.0.5
 Storage Driver: overlay2
  Backing Filesystem: btrfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7c3aca7a610df76212171d200ca3811ff6096eb8
 runc version: 51d5e94601ceffbbd85688df1c928ecccbfa4685
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.7.11-orbstack-00143-ge6b82e26cd22
 Operating System: OrbStack
 OSType: linux
 Architecture: aarch64
 CPUs: 16
 Total Memory: 7.747GiB
 Name: orbstack
 ID: 6930304f-aa9c-4f94-ab8f-65e34ab70164
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine
 Default Address Pools:
   Base: 192.168.215.0/24, Size: 24
   Base: 192.168.228.0/24, Size: 24
   Base: 192.168.247.0/24, Size: 24
   Base: 192.168.207.0/24, Size: 24
   Base: 192.168.167.0/24, Size: 24
   Base: 192.168.107.0/24, Size: 24
   Base: 192.168.237.0/24, Size: 24
   Base: 192.168.148.0/24, Size: 24
   Base: 192.168.214.0/24, Size: 24
   Base: 192.168.165.0/24, Size: 24
   Base: 192.168.227.0/24, Size: 24
   Base: 192.168.181.0/24, Size: 24
   Base: 192.168.158.0/24, Size: 24
   Base: 192.168.117.0/24, Size: 24
   Base: 192.168.155.0/24, Size: 24
   Base: 192.168.147.0/24, Size: 24
   Base: 192.168.229.0/24, Size: 24
   Base: 192.168.183.0/24, Size: 24
   Base: 192.168.156.0/24, Size: 24
   Base: 192.168.97.0/24, Size: 24
   Base: 192.168.171.0/24, Size: 24
   Base: 192.168.186.0/24, Size: 24
   Base: 192.168.216.0/24, Size: 24
   Base: 192.168.242.0/24, Size: 24
   Base: 192.168.166.0/24, Size: 24
   Base: 192.168.239.0/24, Size: 24
   Base: 192.168.223.0/24, Size: 24
   Base: 192.168.164.0/24, Size: 24
   Base: 192.168.163.0/24, Size: 24
   Base: 192.168.172.0/24, Size: 24
   Base: 172.17.0.0/16, Size: 16
   Base: 172.18.0.0/16, Size: 16
   Base: 172.19.0.0/16, Size: 16
   Base: 172.20.0.0/14, Size: 16
   Base: 172.24.0.0/14, Size: 16
   Base: 172.28.0.0/14, Size: 16

I get a similar error if I attempt to build an image for arm64 using my amd64 linux box:

docker buildx build --platform linux/arm64 --file ./Dockerfile --no-cache --progress plain .
# ...
7.858 ==> hex
7.860 Error while loading project :"new package" at /tmp/mix-local-installer-fetcher-Zs6laA/deps/new package
7.920 ** (ArgumentError) could not call Module.put_attribute/3 because the module Hex.MixProject is already compiled
7.920     (elixir 1.16.2) lib/module.ex:2360: Module.assert_not_readonly!/2
7.920     (elixir 1.16.2) lib/module.ex:2041: Module.__put_attribute__/5
7.920     /tmp/mix-local-installer-fetcher-Zs6laA/deps/new package/mix.exs:171: (module)
7.920     (stdlib 5.2.1) lists.erl:1599: :lists.foldl_1/3
------
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
Dockerfile:3
--------------------
   1 |     FROM hexpm/elixir:1.16.2-erlang-26.2.3-alpine-3.19.1
   2 |     RUN apk add git
   3 | >>> RUN mix archive.install github hexpm/hex branch latest --force
   4 |
--------------------
ERROR: failed to solve: process "/dev/.buildkit_qemu_emulator /bin/sh -c mix archive.install github hexpm/hex branch latest --force" did not complete successfully: exit code: 1
Full output
docker buildx build --platform linux/arm64 --file ./Dockerfile --no-cache --progress plain .
#0 building with "nice_pare" instance using docker-container driver

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 171B done
#1 DONE 0.0s

#2 [internal] load metadata for docker.io/hexpm/elixir:1.16.2-erlang-26.2.3-alpine-3.19.1
#2 DONE 1.1s

#3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s

#4 [1/3] FROM docker.io/hexpm/elixir:1.16.2-erlang-26.2.3-alpine-3.19.1@sha256:aed90d87c95d2cb41b2fc589b781ceca11d5faf6e533b89587e741943274a4e7
#4 resolve docker.io/hexpm/elixir:1.16.2-erlang-26.2.3-alpine-3.19.1@sha256:aed90d87c95d2cb41b2fc589b781ceca11d5faf6e533b89587e741943274a4e7 done
#4 CACHED

#5 [2/3] RUN apk add git
#5 0.083 fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/main/aarch64/APKINDEX.tar.gz
#5 0.930 fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/community/aarch64/APKINDEX.tar.gz
#5 2.010 (1/9) Installing brotli-libs (1.1.0-r1)
#5 2.179 (2/9) Installing c-ares (1.27.0-r0)
#5 2.328 (3/9) Installing libunistring (1.1-r2)
#5 2.499 (4/9) Installing libidn2 (2.3.4-r4)
#5 2.592 (5/9) Installing nghttp2-libs (1.58.0-r0)
#5 2.678 (6/9) Installing libcurl (8.5.0-r0)
#5 2.818 (7/9) Installing libexpat (2.6.2-r0)
#5 2.903 (8/9) Installing pcre2 (10.42-r2)
#5 3.032 (9/9) Installing git (2.43.0-r0)
#5 3.500 Executing busybox-1.36.1-r15.trigger
#5 3.560 OK: 26 MiB in 35 packages
#5 DONE 3.7s

#6 [3/3] RUN mix archive.install github hexpm/hex branch latest --force
#6 3.672 * Getting new package (https://github.com/hexpm/hex.git - origin/latest)
#6 5.031 remote: Enumerating objects: 13806, done.
remote: Counting objects: 100% (1261/1261), done.
remote: Compressing objects: 100% (641/641), done.
#6 5.986 remote: Total 13806 (delta 759), reused 993 (delta 562), pack-reused 12545
#6 8.020 ==> hex
#6 8.027 Error while loading project :"new package" at /tmp/mix-local-installer-fetcher-XN3HMA/deps/new package
#6 8.142 ** (ArgumentError) could not call Module.put_attribute/3 because the module Hex.MixProject is already compiled
#6 8.142     (elixir 1.16.2) lib/module.ex:2360: Module.assert_not_readonly!/2
#6 8.142     (elixir 1.16.2) lib/module.ex:2041: Module.__put_attribute__/5
#6 8.142     /tmp/mix-local-installer-fetcher-XN3HMA/deps/new package/mix.exs:171: (module)
#6 8.142     (stdlib 5.2.1) lists.erl:1599: :lists.foldl_1/3
#6 ERROR: process "/dev/.buildkit_qemu_emulator /bin/sh -c mix archive.install github hexpm/hex branch latest --force" did not complete successfully: exit code: 1
------
 > [3/3] RUN mix archive.install github hexpm/hex branch latest --force:
remote: Counting objects: 100% (1261/1261), done.
remote: Compressing objects: 100% (641/641), done.
5.986 remote: Total 13806 (delta 759), reused 993 (delta 562), pack-reused 12545
8.020 ==> hex
8.027 Error while loading project :"new package" at /tmp/mix-local-installer-fetcher-XN3HMA/deps/new package
8.142 ** (ArgumentError) could not call Module.put_attribute/3 because the module Hex.MixProject is already compiled
8.142     (elixir 1.16.2) lib/module.ex:2360: Module.assert_not_readonly!/2
8.142     (elixir 1.16.2) lib/module.ex:2041: Module.__put_attribute__/5
8.142     /tmp/mix-local-installer-fetcher-XN3HMA/deps/new package/mix.exs:171: (module)
8.142     (stdlib 5.2.1) lists.erl:1599: :lists.foldl_1/3
------
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
Dockerfile:3
--------------------
   1 |     FROM hexpm/elixir:1.16.2-erlang-26.2.3-alpine-3.19.1
   2 |     RUN apk add git
   3 | >>> RUN mix archive.install github hexpm/hex branch latest --force
   4 |
--------------------
ERROR: failed to solve: process "/dev/.buildkit_qemu_emulator /bin/sh -c mix archive.install github hexpm/hex branch latest --force" did not complete successfully: exit code: 1
docker system info
Client: Docker Engine - Community
 Version:    25.0.0
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.24.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 15
  Running: 3
  Paused: 0
  Stopped: 12
 Images: 41
 Server Version: 25.0.0
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: error
  NodeID:
  Error: error while loading TLS certificate in /var/lib/docker/swarm/certificates/swarm-node.crt: certificate (1 - iuqe6aimrunn6atv7y4ldcftn) not valid after Sun, 04 Feb 2024 09:18:00 UTC, and it is currently Wed, 14 Feb 2024 16:37:01 CET: x509: certificate has expired or is not yet valid:
  Is Manager: false
  Node Address: 100.126.118.102
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: a1496014c916f9e62104b33d1bb5bd03b0858e59
 runc version: v1.1.11-0-g4bccb38
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.15.0-94-generic
 Operating System: Ubuntu 22.04.3 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 15GiB
 Name: eugene-pc
 ID: 48396c2d-4102-4b10-aa73-6744cad10683
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled:

Any ideas what might be happening here? :thinking:

2 Likes

Did you manage to resolve this?

I’m hitting the same issue at the moment. I imagine that there are more people out there as well, hence the bump here.

After encountering this problem, I decided to document everything I discovered, but chose not to dig further at the moment… So no, didn’t manage to solve this.

I’ll speculate that the problem here is at the intersection of Erlang / qemu, since qemu is typically used by docker buildx to build images across platforms. And if so, it wouldn’t be the first time specific version of Erlang / qemu is affected by this… See: [arm64+otp 25+qemu] `mix local.hex --force` hangs - although there, the problem is even worse, e.g. a segmentation fault. But I am not 100% sure if the two issues are related

1 Like