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.85k stars 283 forks source link

Hover build fails with whitespace in the path to engine cache #184

Open ekasetiawans opened 5 years ago

ekasetiawans commented 5 years ago

My windows username contain whitespace, how to resolve?

hover run
Downloading engine for platform windows-x64 at version 3c51a7bfff...
Download completed in 13.0755136s ?[2K
Downloading artifacts at version 3c51a7bfff...
Download completed in 6.3714326s3 ?[2K
go: finding github.com/go-flutter-desktop/go-flutter v0.23.0
go: finding github.com/go-gl/glfw v0.0.0-20190519095719-e6da0acd62b1
go: finding github.com/pkg/errors v0.8.1
go: finding github.com/stretchr/objx v0.2.0
go: finding github.com/davecgh/go-spew v1.1.1
go: finding github.com/stretchr/testify v1.3.0
go: finding github.com/stretchr/objx v0.1.0
go: finding github.com/davecgh/go-spew v1.1.0
go: finding github.com/pmezard/go-difflib v1.0.0
go: finding github.com/go-gl/glfw latest
go: downloading github.com/go-flutter-desktop/go-flutter v0.23.0
go: extracting github.com/go-flutter-desktop/go-flutter v0.23.0
go: downloading github.com/go-gl/glfw v0.0.0-20190519095719-e6da0acd62b1
go: downloading github.com/pkg/errors v0.8.1
go: extracting github.com/pkg/errors v0.8.1
go: extracting github.com/go-gl/glfw v0.0.0-20190519095719-e6da0acd62b1
# runtime/cgo
gcc: error: Setiawan: No such file or directory
gcc: error: Saputra\AppData\Local\hover\engine\windows: No such file or directory
Go get -u github.com/go-flutter-desktop/go-flutter failed: exit status 2
pchampio commented 5 years ago

related to #125 @GeertJohan is hover feature/escape-spaces ready to be merged?

GeertJohan commented 5 years ago

No, it was a try to fix the issue, but didn't work. I don't have a windows machine so it's hard to test this. Help is welcome.

ekasetiawans commented 5 years ago

I have try https://github.com/go-flutter-desktop/hover/compare/feature/escape-spaces and compile it but it's not resolve the problem

GeertJohan commented 5 years ago

A workarround has been added to Hover (thanks @Drakirus!). Use --cache-path with a simple path (that does not contain spaces). e.g.:

hover run --cache-path=C:\cache

Will keep this issue open as the underlying issue is not yet fixed. Hover should work out-of-the-box, also with spaces in the path (most often on Windows due to usernames)

ekasetiawans commented 5 years ago

Thank you, I will try

ghost commented 5 years ago

Does hover work now ?

hover.exe run --cache-path=D:\cache
hover: Downloading engine for platform windows-x64 at version 54ad777fd2...
hover: Download completed in 3.93s
hover: Downloading artifacts at version 54ad777fd2...
hover: Download completed in 1.88s
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)
go: finding github.com/go-gl/glfw latest
# github.com/go-flutter-desktop/go-flutter/embedder
D:\cache\hover\engine\windows/flutter_engine.dll: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
hover: Updating go-flutter to latest version failed: exit status 2

** size
23M 23681536 'D:\cache\hover\engine\windows\flutter_engine.dll'

** md5
31115ef1437aa3bfc12bdc2f5232f652 *D:\\cache\\hover\\engine\\windows\\flutter_engine.dll

** gcc version
gcc version 9.1.0 (Rev3, Built by MSYS2 project)
** go version
go version go1.12.7 windows/386
pchampio commented 5 years ago

@di3663 your issue isn't related to the spaces in the path. Your issue is now described in #195

ghost commented 5 years ago

@di3663 your issue isn't related to the spaces in the path. Your issue is now described in #195

Ok. Thanks. Yesterday I wanted to check whether ime is supported better these days. Chinese input methods are not supported well in all opengl projects on windows, not even gtk. We can input of course. And win32 may still a more common platform.

altermark commented 4 years ago

AFAICT engineCachePath is stored to CGO_LDFLAGS

https://github.com/go-flutter-desktop/hover/blob/master/cmd/build.go#L470-L478

and passed to cgo, where the flags are parsed.

https://github.com/golang/go/blob/c5d7f2f1cbaca8938a31a022058b1a3300817e33/src/cmd/cgo/main.go#L289

Used parser function supports escaping of special characters

https://groups.google.com/forum/#!topic/golang-nuts/aNDB4FrmEiA https://github.com/golang/go/blob/c5d7f2f1cbaca8938a31a022058b1a3300817e33/src/cmd/cgo/gcc.go#L104-L120

But it seems that even when the path with spaces is correctly parsed by cgo, it breaks further down when it's passed to the C compiler. So the best solution would probably be to fix cgo. There have been several issues filled already along similar lines but without apparent resolution:

https://github.com/golang/go/issues/7906 https://github.com/golang/go/issues/11868 https://github.com/golang/go/issues/16455

Nevertheless it may be that engineCachePath does not need to be included in CGO_LDFLAGS, since (at least on my computer, Win10, mingw-w64) it does not contain any libraries that C compiler needs. So when I changed

https://github.com/go-flutter-desktop/hover/blob/master/cmd/build.go#L478

cgoLdflags += fmt.Sprintf(" -L%s -L%s", engineCachePath, outputDirPath)

into

cgoLdflags += fmt.Sprintf(" -L%s", outputDirPath)

and removed space check in https://github.com/go-flutter-desktop/hover/blob/master/internal/enginecache/cache.go#L208-L214 my test project compiled and run without issues.

I can't speak for other OSes or configurations though.