go-flutter-desktop / go-flutter

Flutter on Windows, MacOS and Linux - based on Flutter Embedding, Go and GLFW.
https://hover.build/
BSD 3-Clause "New" or "Revised" License
5.87k stars 283 forks source link

windows-msi build error with docker, linux-deb build not working even though should be possible #546

Closed sidevesh closed 3 years ago

sidevesh commented 3 years ago

Looks like with the recent updates to hover, its not possible to compile for a platform from different host platform even with the --docker option. Is that the case really ? I am trying to compile ubuntu and windows packages from macOS with the --docker option and I am getting the following output:

For linux-deb:

swapn@Swapnils-MacBook-Pro tomatoroapp % hover build linux-deb --docker
hover: AOT builds currently only work on their host OS

Also I changed the checks in code to allow running linux-deb packaging with docker option, and on trying to build it, got the following error:

swapn@Swapnils-MacBook-Pro tomatoroapp % hover build linux-deb --docker
hover: Downloading engine for platform linux-release at version 5babba6c4d25fa237bbf755ab85c9a0c50b3c6ec...
Download completed in 45.03s
hover: Failed to strip /Users/swapn/Library/Caches/hover/engine/linux-release/libflutter_engine.so: exit status 1

For windows-msi:

swapn@Swapnils-MacBook-Pro tomatoroapp % hover build windows-msi --docker
hover: Using engine from cache
hover: Building using docker container
Running this docker command: /usr/local/bin/docker run --rm --mount type=bind,source=/Users/swapn/Documents/Projects/Tomatoro/tomatoroapp,target=/app --mount type=bind,source=/Users/swapn/Library/Caches/hover/engine,target=/root/.cache/hover/engine --mount type=bind,source=/Users/swapn/Library/Caches/hover/docker-go-cache,target=/go-cache --env GOCACHE=/go-cache --env HOVER_SAFE_CHOWN_UID=501 --env HOVER_SAFE_CHOWN_GID=20 --env GOPROXY=https://proxy.golang.org,direct
 --env GOPRIVATE=
 goflutter/hover:latest hover-safe.sh build windows-msi --skip-engine-download --version-number 1.0.20+24
docker container: docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /host_mnt/Users/swapn/Library/Caches/hover/engine.
docker container: See 'docker run --help'.
hover: Docker run failed: exit status 125

Building for linux from docker with macOS shhould be possible since docker on macOS runs inside linux VM. Not sure why the error for windows-msi happens.

hover doctor output:

hover: Hover version (devel) running on darwin
hover: Sharing packaging tools
hover: darwin-bundle is supported
hover: darwin-dmg is supported
hover: darwin-pkg is supported
hover: Packaging linux-appimage is not supported on darwin
hover: To still package linux-appimage on darwin you need to run hover with the `--docker` flag.
hover: Packaging linux-deb is not supported on darwin
hover: To still package linux-deb on darwin you need to run hover with the `--docker` flag.
hover: Packaging linux-pkg is not supported on darwin
hover: To still package linux-pkg on darwin you need to run hover with the `--docker` flag.
hover: Packaging linux-rpm is not supported on darwin
hover: To still package linux-rpm on darwin you need to run hover with the `--docker` flag.
hover: Packaging linux-snap is not supported on darwin
hover: To still package linux-snap on darwin you need to run hover with the `--docker` flag.
hover: Packaging windows-msi is not supported on darwin
hover: To still package windows-msi on darwin you need to run hover with the `--docker` flag.
hover: 
hover: Sharing flutter version
Flutter 1.22.0 • channel unknown • unknown source
Framework • revision d408d302e2 (3 months ago) • 2020-09-29 11:49:17 -0700
Engine • revision 5babba6c4d
Tools • Dart 2.10.0
hover: Flutter engine commit: https://github.com/flutter/engine/commit/5babba6c4d25fa237bbf755ab85c9a0c50b3c6ec
hover: ⚠ The go-flutter project tries to stay compatible with the beta channel of Flutter.
hover: ⚠     It's advised to use the beta channel: `flutter channel beta`
hover: Finding out the C compiler version
Apple clang version 12.0.0 (clang-1200.0.32.2)
Target: x86_64-apple-darwin20.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
hover: Sharing the content of go.mod
module tomatoro/go

go 1.13

require (
        github.com/BestBurning/platform_device_id/go v0.1.1
        github.com/deckarep/gosx-notifier v0.0.0-20180201035817-e127226297fb // indirect
        github.com/go-flutter-desktop/go-flutter v0.42.0
        github.com/go-flutter-desktop/plugins/package_info v0.0.0-20200415181852-215d9c007301
        github.com/go-flutter-desktop/plugins/path_provider v0.3.3
        github.com/go-flutter-desktop/plugins/shared_preferences v0.4.3
        github.com/go-flutter-desktop/plugins/url_launcher v0.1.2
        github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1
        github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200707082815-5321531c36a2
        github.com/martinlindhe/notify v0.0.0-20181008203735-20632c9a275a
        github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
        github.com/pkg/errors v0.9.1
        github.com/sidevesh/go-flutter-plugin-sqflite v0.0.0-20200718224941-b1ba30c6bdda
        gopkg.in/toast.v1 v1.0.0-20180812000517-0a84660828b2 // indirect
)
hover: Sharing the content of hover.yaml
application-name: Tomatoro
executable-name: ""
package-name: ""
license: UNLICENSED
target: lib/main_desktop.dart
branch: ""
cache-path: ""
opengl: ""
engine-version: ""
hover: Sharing the content of go/cmd
go/cmd/desktop_local_notifications.go   go/cmd/main.go  go/cmd/options.go       go/cmd/transparent_title_bar_darwin.go  go/cmd/transparent_title_bar_unsupported.go
sidevesh commented 3 years ago

Would love to implement and fix this myself :) Just need some directions though on what the issue might be for not being able to support this.

provokateurin commented 3 years ago

Are you sure you have the latest code? You also need to run ./install-with-docker-image.sh to update the image locally. What you show should be fixed in the latest version (I tagged it now). Anyway I'll look at the code and see if the problem is there.

provokateurin commented 3 years ago

Ok I see the problem. Let me fix it quickly

provokateurin commented 3 years ago

You can either use that PR or the hidden --ignore-host-os flag for now.

sidevesh commented 3 years ago

hey @jld3103 , so I did the exact same change to get linux packages working with docker, didn't work though with the following error:

swapn@Swapnils-MacBook-Pro tomatoroapp % hover build linux-deb --docker
hover: Downloading engine for platform linux-release at version 5babba6c4d25fa237bbf755ab85c9a0c50b3c6ec...
Download completed in 45.03s
hover: Failed to strip /Users/swapn/Library/Caches/hover/engine/linux-release/libflutter_engine.so: exit status 1
sidevesh commented 3 years ago

also am I correct in assuming that compiling windows-msi would not work at all except when building on base os windows itself, docker or no docker ?

provokateurin commented 3 years ago

Is that the full log? From hover doctor I can see that your flutter channel is unknown. Please switch to beta, dev or master. That might fix the problem.

provokateurin commented 3 years ago

Cross-compiling windows-msi is possible from windows, docker and linux or darwin with wine and msi-tools.

sidevesh commented 3 years ago

okay, even on beta flutter, the linux-deb packaging fails with the same error, windows-msi packaging fails now on beta with:

swapn@Swapnils-MacBook-Pro tomatoroapp % hover build windows-msi --docker
hover: Downloading engine for platform windows-release at version 9a28c3bcf40ce64fee61e807ee3e1395fd6bd954...
hover: Failed to download engine: failed to get Content-Length header: strconv.Atoi: parsing "": invalid syntax
hover: Engine builds are a bit delayed after they are published in flutter.
hover: You can either try again later or switch the flutter channel to beta, because these engines are more likely to be already built.
hover: To dig into the already built engines look at https://github.com/flutter-rs/engine-builds/releases and https://github.com/flutter-rs/engine-builds/actions
provokateurin commented 3 years ago

Ah I know what the error is. Wait a minute

provokateurin commented 3 years ago

Yeah some engines builds are not available. The current master engine does work

provokateurin commented 3 years ago

I updated the PR. If you switch to master channel and try the PR it should work now

sidevesh commented 3 years ago

Tried with the updated pr after hover clean-cache, getting the following error, which seems similar to the windows-msi error I mentioned in the original issue,

swapn@Swapnils-MacBook-Pro tomatoroapp % hover build linux-deb --docker  
hover: Using engine from cache
hover: Building using docker container
Running this docker command: /usr/local/bin/docker run --rm --mount type=bind,source=/Users/swapn/Documents/Projects/Tomatoro/tomatoroapp,target=/app --mount type=bind,source=/Users/swapn/Library/Caches/hover/engine,target=/root/.cache/hover/engine --mount type=bind,source=/Users/swapn/Library/Caches/hover/docker-go-cache,target=/go-cache --env GOCACHE=/go-cache --env HOVER_SAFE_CHOWN_UID=501 --env HOVER_SAFE_CHOWN_GID=20 --env GOPROXY=https://proxy.golang.org,direct
 --env GOPRIVATE=
 goflutter/hover:latest hover-safe.sh build linux-deb --skip-engine-download --version-number 1.0.20+24
docker container: docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /host_mnt/Users/swapn/Library/Caches/hover/engine.
docker container: See 'docker run --help'.
hover: Docker run failed: exit status 125
provokateurin commented 3 years ago

So somehow the cache directory isn't mounted.

provokateurin commented 3 years ago

Did hover download the engine? And can you see until which directory /Users/swapn/Library/Caches/hover/engine exists?

provokateurin commented 3 years ago

(Btw to get better formatted code blocks use three `)

sidevesh commented 3 years ago
swapn@Swapnils-MacBook-Pro tomatoroapp % tree /Users/swapn/Library/Caches/hover/engine
/Users/swapn/Library/Caches/hover/engine
├── linux-release
│   ├── dart
│   ├── flutter_patched_sdk
│   │   ├── platform_strong.dill
│   │   ├── platform_strong.dill.d
│   │   └── vm_outline_strong.dill
│   ├── gen
│   │   └── frontend_server.dart.snapshot
│   ├── gen_snapshot
│   ├── icudtl.dat
│   ├── libflutter_engine.so
│   └── version
└── windows-release

4 directories, 9 files
provokateurin commented 3 years ago

Ok so it exists and looks fine. Somehow docker tries to mount /host_mnt/Users/swapn/Library/Caches/hover/engine while it actually should mount /Users/swapn/Library/Caches/hover/engine.

provokateurin commented 3 years ago

This looks like it is the same: https://github.com/docker/for-mac/issues/4859

sidevesh commented 3 years ago

that was the cause! Switching to osxfs as mentioned on that issue fixes that error, and the build goes quite a bit far but eventually fails with:

...
docker container: +file:///root/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.2.0-nullsafety.3/lib/src/generated/glyph_set.dart
docker container: +file:///root/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.2.0-nullsafety.3/lib/src/generated/top_level.dart
docker container: +file:///root/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.2.0-nullsafety.3/lib/src/generated/ascii_glyph_set.dart
docker container: +file:///root/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.2.0-nullsafety.3/lib/src/generated/unicode_glyph_set.dart
docker container: +file:///root/.pub-cache/hosted/pub.dartlang.org/source_span-1.8.0-nullsafety.4/lib/src/colors.dart
docker container: 29827ebb-5c72-4a0b-b5f7-e0b0c4a86695 /app/go/build/outputs/linux-release/kernel_snapshot.dill 33775
docker container: hover: Generating kernel snapshot failed: exit status 254
hover: Docker run failed: exit status 1
provokateurin commented 3 years ago

Can you post the full log of that command?

sidevesh commented 3 years ago

hover-linux-deb.log its quite long, but here you go. @jld3103

provokateurin commented 3 years ago

The problem is The specified language version is too high. The highest supported language version is 2.9. This happens because your local flutter version is higher than the one in the container and resolves packages that support non-nullability. If you switch to the beta channel, run flutter pub upgrade and then the command again it should work. At least that fixed it for me. Officially go-flutter only supports the beta channel so master is not a good idea as you can see. Sorry for misleading you to that.

sidevesh commented 3 years ago

That fixed it, thanks for the help @jld3103 ! We can probably merge fix/linux-aot-cross-compilation, looks like a good fix to me :)