go-flutter icon indicating copy to clipboard operation
go-flutter copied to clipboard

Hover build fails with whitespace in the path to engine cache

Open ekasetiawans opened this issue 5 years ago • 9 comments

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

ekasetiawans avatar Jul 04 '19 09:07 ekasetiawans

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

pchampio avatar Jul 04 '19 09:07 pchampio

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.

GeertJohan avatar Jul 04 '19 11:07 GeertJohan

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

ekasetiawans avatar Jul 08 '19 01:07 ekasetiawans

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)

GeertJohan avatar Jul 10 '19 16:07 GeertJohan

Thank you, I will try

ekasetiawans avatar Jul 10 '19 16:07 ekasetiawans

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[2K
hover: Downloading artifacts at version 54ad777fd2...
hover: Download completed in 1.88s[2K
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

ghost avatar Jul 16 '19 10:07 ghost

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

pchampio avatar Jul 16 '19 15:07 pchampio

@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.

ghost avatar Jul 17 '19 10:07 ghost

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.

altermark avatar Jul 16 '20 21:07 altermark