Need Documenetation Guide On How To Build Rust On Raspberry Pi With armv7-unknown-linux-musleabihf Platform

Dear Sir/Madam,

Good day.

I've have some errors in installing rust for Raspberry Pi using armv7-unknown-linux-musleabihf platform, which is not supported.

Full Error Logs:

Error response from daemon: No such image: test-api:latest
[+] Building 24.9s (10/11)                                                                               docker:default
 => [internal] load .dockerignore                                                                                  0.0s
 => => transferring context: 2B                                                                                    0.0s
 => [internal] load build definition from Dockerfile                                                               0.0s
 => => transferring dockerfile: 1.00kB                                                                             0.0s
 => [internal] load metadata for                                               2.2s
 => [1/7] FROM  0.0s
 => [internal] load build context                                                                                  0.0s
 => => transferring context: 21.78kB                                                                               0.0s
 => CACHED [2/7] WORKDIR /root                                                                                     0.0s
 => CACHED [3/7] COPY ./requirements.txt /root/requirements.txt                                                    0.0s
 => CACHED [4/7] RUN apk --no-cache add curl                                                                       0.0s
 => CACHED [5/7] RUN curl --version                                                                                0.0s
 => ERROR [6/7] RUN pip install --no-cache-dir --upgrade -r /root/requirements.txt                                22.5s
 > [6/7] RUN pip install --no-cache-dir --upgrade -r /root/requirements.txt:
7.542 Collecting requests>=2.28.1
7.646   Downloading requests-2.31.0-py3-none-any.whl (62 kB)
7.665      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 kB 6.9 MB/s eta 0:00:00
8.006 Collecting fastapi>=0.79.1
8.016   Downloading fastapi-0.103.0-py3-none-any.whl (66 kB)
8.028      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 66.2/66.2 kB 19.6 MB/s eta 0:00:00
8.352 Collecting fastapi-versioning>=0.10.0
8.363   Downloading fastapi_versioning-0.10.0-py3-none-any.whl (4.9 kB)
8.498 Collecting uvicorn>=0.18.2
8.509   Downloading uvicorn-0.23.2-py3-none-any.whl (59 kB)
8.521      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 59.5/59.5 kB 18.6 MB/s eta 0:00:00
8.608 Collecting PyJWT>=2.4.0
8.619   Downloading PyJWT-2.8.0-py3-none-any.whl (22 kB)
8.956 Collecting charset-normalizer<4,>=2
8.968   Downloading charset_normalizer-3.2.0-py3-none-any.whl (46 kB)
8.978      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 46.7/46.7 kB 18.2 MB/s eta 0:00:00
9.035 Collecting idna<4,>=2.5
9.047   Downloading idna-3.4-py3-none-any.whl (61 kB)
9.059      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 kB 18.3 MB/s eta 0:00:00
9.150 Collecting certifi>=2017.4.17
9.161   Downloading certifi-2023.7.22-py3-none-any.whl (158 kB)
9.179      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 158.3/158.3 kB 19.0 MB/s eta 0:00:00
9.644 Collecting urllib3<3,>=1.21.1
9.656   Downloading urllib3-2.0.4-py3-none-any.whl (123 kB)
9.672      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 123.9/123.9 kB 19.7 MB/s eta 0:00:00
10.46 Collecting pydantic!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,!=2.1.0,<3.0.0,>=1.7.4
10.47   Downloading pydantic-2.3.0-py3-none-any.whl (374 kB)
10.50      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 374.5/374.5 kB 18.7 MB/s eta 0:00:00
10.65 Collecting starlette<0.28.0,>=0.27.0
10.66   Downloading starlette-0.27.0-py3-none-any.whl (66 kB)
10.68      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 67.0/67.0 kB 18.7 MB/s eta 0:00:00
11.00 Collecting typing-extensions>=4.5.0
11.01   Downloading typing_extensions-4.7.1-py3-none-any.whl (33 kB)
11.21 Collecting h11>=0.8
11.22   Downloading h11-0.14.0-py3-none-any.whl (58 kB)
11.23      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.3/58.3 kB 19.4 MB/s eta 0:00:00
11.64 Collecting click>=7.0
11.65   Downloading click-8.1.7-py3-none-any.whl (97 kB)
11.66      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.9/97.9 kB 20.4 MB/s eta 0:00:00
11.87 Collecting annotated-types>=0.4.0
11.88   Downloading annotated_types-0.5.0-py3-none-any.whl (11 kB)
14.39 Collecting pydantic-core==2.6.3
14.65   Downloading pydantic_core-2.6.3.tar.gz (337 kB)
14.68      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 337.2/337.2 kB 16.6 MB/s eta 0:00:00
14.98   Installing build dependencies: started
21.08   Installing build dependencies: finished with status 'done'
21.09   Getting requirements to build wheel: started
21.30   Getting requirements to build wheel: finished with status 'done'
21.31   Preparing metadata (pyproject.toml): started
21.51   Preparing metadata (pyproject.toml): finished with status 'error'
21.53   error: subprocess-exited-with-error
21.53   × Preparing metadata (pyproject.toml) did not run successfully.
21.53   │ exit code: 1
21.53   ╰─> [6 lines of output]
21.53       Cargo, the Rust package manager, is not installed or is not on PATH.
21.53       This package requires Rust and Cargo to compile extensions. Install it through
21.53       the system's package manager or via
21.53       Checking for Rust toolchain....
21.53       [end of output]
21.53   note: This error originates from a subprocess, and is likely not a problem with pip.
21.54 error: metadata-generation-failed
21.54 × Encountered error while generating package metadata.
21.54 ╰─> See above for output.
21.54 note: This is an issue with the package mentioned above, not pip.
21.54 hint: See above for details.
21.87 [notice] A new release of pip is available: 23.0.1 -> 23.2.1
21.87 [notice] To update, run: pip install --upgrade pip
  33 |     # RUN cargo --help
  34 |
  35 | >>> RUN pip install --no-cache-dir --upgrade -r /root/requirements.txt
  36 |
  37 |     COPY ./app /root/app
ERROR: failed to solve: process "/bin/sh -c pip install --no-cache-dir --upgrade -r /root/requirements.txt" did not complete successfully: exit code: 1

Could provide the full documentation so we could build on it successfully?

Similar Issue:

Thank you.

can you please describe your problem with more detail? for example, are you trying to build the rust toolchain for raspberry pi from a raspberry pi host? or are you cross compiling from a PC? what command line are you running? details like these can greatly reduce the guessing work for people who want to offer help.

to my knowledge, the armv7 and linux combination is a well supported platform, it's just the musl variant is tier2. is there any reason you can't use armv7-unknown-linux-gnueabihf? armv7-unknown-linux-gnueabihf is better supported and can be installed directly using rustup.

I'd suggest you use the gnu variant if possible, you can always cross-compile to the armv7-unknown-linux-musleabihf target for your library or application.

Hi @nerditation ,

Thanks for your reply.

For your info, actually I did not expected to compile rust manually in the first place.

What I'm expecting is just to install pypi requirements.txt successfully via Dockerfile and ensure Docker image is up.

Dockerfile Code:

FROM python:3.9-alpine


COPY ./requirements.txt /root/requirements.txt

# Install Curl Library
RUN apk --no-cache add curl

# Validate curl Installation
RUN curl --version

RUN pip install --no-cache-dir --upgrade -r /root/requirements.txt

COPY ./app /root/app

CMD ["uvicorn", "app.main:app", "--host", "", "--port", "8000"]

requirements.txt Code:


So I'm clueless how could I compile rust manually and integrate it into existing Dockerfile.


oh, I see, it's actually a python package that needs to be built with rust. from the log message:

I assume it's the pydantic-core package. and indeed, the "Getting Started" section of the document

oops, accidentally hit send button.

the document of pydantic-core states:

You'll need rust stable installed, or rust nightly if you want to generate accurate coverage.

I don't know how python package distribute artifacts, from the listing here:

there's no pre-built binary file for armv7 combination with linux-musl. so I suppose potentially 2 solutions might be possible:

  • contact the maintainer of pydantic-core to see if they can add a prebuilt binary package to the pypi registry
  • ditch the alpine linxu and use a gnu variant of linux as your base docker image
    • for example debian or ubuntu should all work on raspberry pi I think.


noticed your origin dockerfile used python-3.9-alpine, so presumably there should be a python-3.9-slim or similar tag. search slim, bullseye or bookworm for debian based images.

Thank you your suggestion works indeed.

Alternatively, changing Fast API to old version before 0.79.1 is working fine without rust compilation error.


Thanks a lot @nerditation !

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.