Flutter installation on Alpine Linux container is unable to 'pub upgrade'
Asked Answered
P

1

8

I would like to install Flutter on a Docker container running Alpine Linux.

I wrote the following Dockerfile:

FROM alpine

RUN apk add bash curl file git zip
RUN git clone https://github.com/flutter/flutter.git
ENV PATH="$PATH:/flutter/bin"
RUN flutter channel stable

Everything goes fine until the last step, where I get:

Step 5/5 : RUN flutter channel stable
 ---> Running in f8e764b1e091
Downloading Dart SDK from Flutter engine 82b4ae86d69b4bad10a42ad380f2a538d97ffb38...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  174M  100  174M    0     0  23.1M      0  0:00:07  0:00:07 --:--:-- 23.8M
Building flutter tool...
/flutter/bin/cache/dart-sdk/bin/pub: line 49: /flutter/bin/cache/dart-sdk/bin/dart: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (9 tries left)
/flutter/bin/cache/dart-sdk/bin/pub: line 49: /flutter/bin/cache/dart-sdk/bin/dart: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (8 tries left)
/flutter/bin/cache/dart-sdk/bin/pub: line 49: /flutter/bin/cache/dart-sdk/bin/dart: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (7 tries left)
/flutter/bin/cache/dart-sdk/bin/pub: line 49: /flutter/bin/cache/dart-sdk/bin/dart: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (6 tries left)
/flutter/bin/cache/dart-sdk/bin/pub: line 49: /flutter/bin/cache/dart-sdk/bin/dart: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (5 tries left)
/flutter/bin/cache/dart-sdk/bin/pub: line 49: /flutter/bin/cache/dart-sdk/bin/dart: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (4 tries left)
/flutter/bin/cache/dart-sdk/bin/pub: line 49: /flutter/bin/cache/dart-sdk/bin/dart: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (3 tries left)
/flutter/bin/cache/dart-sdk/bin/pub: line 49: /flutter/bin/cache/dart-sdk/bin/dart: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (2 tries left)
/flutter/bin/cache/dart-sdk/bin/pub: line 49: /flutter/bin/cache/dart-sdk/bin/dart: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (1 tries left)
Command 'pub upgrade' still failed after 10 tries, giving up.
The command '/bin/sh -c flutter channel stable' returned a non-zero code: 1

Why?

Note

I tried:

  • running flutter doctor instead of flutter channel stable -- still the same problem
  • using the root user -- still the same problem
  • using Ubuntu instead of Alpine -- works as expected, but I'd like to use Alpine
Portie answered 2/1, 2021 at 16:39 Comment(3)
I guess the related issue you created on their tracker github.com/flutter/flutter/issues/73260Busby
Yep. Thank you for mentioning it here.Portie
tl;dr dart not available on alpine. afaik it's worked on but definitely no dart package for alpine on arm --=> github.com/dart-lang/sdk/issues/51642#issuecomment-1498454291Twinberry
N
0

I found a working solution in the issue created by OP. Simply add gcompat to your packages.

Working (partial) Dockerfile

FROM alpine
RUN apk update

## Make sure to install gcompat
RUN apk add bash curl file git unzip which zip gcompat

# # download Flutter SDK from Flutter Github repo
RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter

# # Set flutter environment path
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"

# # Run flutter doctor
RUN flutter doctor

# # Enable flutter web
RUN flutter channel master
RUN flutter upgrade
RUN flutter config --enable-web
Nady answered 9/1 at 6:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.