Closed hbollon closed 3 years ago
the one for Linux is an .ar file
This is weird because in your logs there's Moving /home/hbollon/Documents/Projects/igopher/output/linux-amd64/binary to /home/hbollon/Documents/Projects/igopher/output/linux-amd64/IGopher
which means the linux
binary is located at /home/hbollon/Documents/Projects/igopher/output/linux-amd64/IGopher
But these don't work
Are you on Linux? If so, can you run /home/hbollon/Documents/Projects/igopher/output/linux-amd64/IGopher
in the terminal and paste logs here? It will tell us more about why binary is not working
I redone everything and there is the output:
❯ astilectron-bundler cc && astilectron-bundler
2021/03/03 10:44:43 Removing /tmp/astibundler/cache
2021/03/03 10:44:43 Bundling for environment darwin/amd64
2021/03/03 10:44:43 Binding data
2021/03/03 10:44:43 Removing /tmp/astibundler/bind
2021/03/03 10:44:43 Creating /tmp/astibundler/bind
2021/03/03 10:44:43 Creating /tmp/astibundler/bind/vendor_astilectron_bundler
2021/03/03 10:44:43 Creating /tmp/astibundler/cache
2021/03/03 10:44:43 Downloading https://github.com/asticode/astilectron/archive/v0.44.0.zip into /tmp/astibundler/cache/astilectron-0.44.0.zip
2021/03/03 10:44:43 astikit: sending GET request to https://github.com/asticode/astilectron/archive/v0.44.0.zip (1/1)
2021/03/03 10:44:44 Copying /tmp/astibundler/cache/astilectron-0.44.0.zip to /tmp/astibundler/bind/vendor_astilectron_bundler/astilectron.zip
2021/03/03 10:44:44 Downloading https://github.com/electron/electron/releases/download/v11.1.0/electron-v11.1.0-darwin-x64.zip into /tmp/astibundler/cache/electron-darwin-amd64-11.1.0.zip
2021/03/03 10:44:44 astikit: sending GET request to https://github.com/electron/electron/releases/download/v11.1.0/electron-v11.1.0-darwin-x64.zip (1/1)
2021/03/03 10:48:02 Copying /tmp/astibundler/cache/electron-darwin-amd64-11.1.0.zip to /tmp/astibundler/bind/vendor_astilectron_bundler/electron.zip
2021/03/03 10:48:03 Creating /tmp/astibundler/bind/resources
2021/03/03 10:48:03 Copying /home/hbollon/Documents/Projects/igopher/cmd/igopher/gui/resources to /tmp/astibundler/bind/resources
2021/03/03 10:48:03 Generating /home/hbollon/Documents/Projects/igopher/bind_darwin_amd64.go
2021/03/03 10:48:05 Removing /home/hbollon/Documents/Projects/igopher/output/darwin-amd64
2021/03/03 10:48:05 Creating /home/hbollon/Documents/Projects/igopher/output/darwin-amd64
2021/03/03 10:48:05 Building for os darwin and arch amd64 astilectron: 0.44.0 electron: 11.1.0
2021/03/03 10:48:05 Executing go build -ldflags -X "igopher.AppName=IGopher" -X "igopher.BuiltAt=2021-03-03 10:48:05.88660307 +0100 CET m=+202.809256834" -X "igopher.VersionAstilectron=0.44.0" -X "igopher.VersionElectron=11.1.0" -o /home/hbollon/Documents/Projects/igopher/output/darwin-amd64/binary .
2021/03/03 10:48:21 Creating /home/hbollon/Documents/Projects/igopher/output/darwin-amd64/IGopher.app/Contents/MacOS
2021/03/03 10:48:21 Moving /home/hbollon/Documents/Projects/igopher/output/darwin-amd64/binary to /home/hbollon/Documents/Projects/igopher/output/darwin-amd64/IGopher.app/Contents/MacOS/IGopher
2021/03/03 10:48:21 Chmoding /home/hbollon/Documents/Projects/igopher/output/darwin-amd64/IGopher.app/Contents/MacOS/IGopher
2021/03/03 10:48:21 Creating /home/hbollon/Documents/Projects/igopher/output/darwin-amd64/IGopher.app/Contents/Resources
2021/03/03 10:48:21 Copying /home/hbollon/Documents/Projects/igopher/cmd/igopher/gui/resources/favicon.icns to /home/hbollon/Documents/Projects/igopher/output/darwin-amd64/IGopher.app/Contents/Resources/IGopher.icns
2021/03/03 10:48:21 Adding Info.plist to /home/hbollon/Documents/Projects/igopher/output/darwin-amd64/IGopher.app/Contents/Info.plist
2021/03/03 10:48:21 Bundling for environment linux/amd64
2021/03/03 10:48:21 Binding data
2021/03/03 10:48:21 Removing /tmp/astibundler/bind
2021/03/03 10:48:21 Creating /tmp/astibundler/bind
2021/03/03 10:48:21 Creating /tmp/astibundler/bind/vendor_astilectron_bundler
2021/03/03 10:48:21 Creating /tmp/astibundler/cache
2021/03/03 10:48:21 /tmp/astibundler/cache/astilectron-0.44.0.zip already exists, skipping download of https://github.com/asticode/astilectron/archive/v0.44.0.zip
2021/03/03 10:48:21 Copying /tmp/astibundler/cache/astilectron-0.44.0.zip to /tmp/astibundler/bind/vendor_astilectron_bundler/astilectron.zip
2021/03/03 10:48:21 Downloading https://github.com/electron/electron/releases/download/v11.1.0/electron-v11.1.0-linux-x64.zip into /tmp/astibundler/cache/electron-linux-amd64-11.1.0.zip
2021/03/03 10:48:21 astikit: sending GET request to https://github.com/electron/electron/releases/download/v11.1.0/electron-v11.1.0-linux-x64.zip (1/1)
2021/03/03 10:56:41 Copying /tmp/astibundler/cache/electron-linux-amd64-11.1.0.zip to /tmp/astibundler/bind/vendor_astilectron_bundler/electron.zip
2021/03/03 10:56:41 Creating /tmp/astibundler/bind/resources
2021/03/03 10:56:41 Copying /home/hbollon/Documents/Projects/igopher/cmd/igopher/gui/resources to /tmp/astibundler/bind/resources
2021/03/03 10:56:41 Generating /home/hbollon/Documents/Projects/igopher/bind_linux_amd64.go
2021/03/03 10:56:49 Removing /home/hbollon/Documents/Projects/igopher/output/linux-amd64
2021/03/03 10:56:49 Creating /home/hbollon/Documents/Projects/igopher/output/linux-amd64
2021/03/03 10:56:49 Building for os linux and arch amd64 astilectron: 0.44.0 electron: 11.1.0
2021/03/03 10:56:49 Executing go build -ldflags -X "igopher.AppName=IGopher" -X "igopher.BuiltAt=2021-03-03 10:56:49.202874376 +0100 CET m=+726.125528144" -X "igopher.VersionAstilectron=0.44.0" -X "igopher.VersionElectron=11.1.0" -o /home/hbollon/Documents/Projects/igopher/output/linux-amd64/binary .
2021/03/03 10:57:00 Moving /home/hbollon/Documents/Projects/igopher/output/linux-amd64/binary to /home/hbollon/Documents/Projects/igopher/output/linux-amd64/IGopher
2021/03/03 10:57:00 Bundling for environment windows/amd64
2021/03/03 10:57:00 Binding data
2021/03/03 10:57:00 Removing /tmp/astibundler/bind
2021/03/03 10:57:00 Creating /tmp/astibundler/bind
2021/03/03 10:57:00 Creating /tmp/astibundler/bind/vendor_astilectron_bundler
2021/03/03 10:57:00 Creating /tmp/astibundler/cache
2021/03/03 10:57:00 /tmp/astibundler/cache/astilectron-0.44.0.zip already exists, skipping download of https://github.com/asticode/astilectron/archive/v0.44.0.zip
2021/03/03 10:57:00 Copying /tmp/astibundler/cache/astilectron-0.44.0.zip to /tmp/astibundler/bind/vendor_astilectron_bundler/astilectron.zip
2021/03/03 10:57:00 Downloading https://github.com/electron/electron/releases/download/v11.1.0/electron-v11.1.0-win32-x64.zip into /tmp/astibundler/cache/electron-windows-amd64-11.1.0.zip
2021/03/03 10:57:00 astikit: sending GET request to https://github.com/electron/electron/releases/download/v11.1.0/electron-v11.1.0-win32-x64.zip (1/1)
2021/03/03 11:04:48 Copying /tmp/astibundler/cache/electron-windows-amd64-11.1.0.zip to /tmp/astibundler/bind/vendor_astilectron_bundler/electron.zip
2021/03/03 11:04:48 Creating /tmp/astibundler/bind/resources
2021/03/03 11:04:48 Copying /home/hbollon/Documents/Projects/igopher/cmd/igopher/gui/resources to /tmp/astibundler/bind/resources
2021/03/03 11:04:48 Generating /home/hbollon/Documents/Projects/igopher/bind_windows_amd64.go
2021/03/03 11:04:55 Running rsrc for icon /home/hbollon/Documents/Projects/igopher/cmd/igopher/gui/resources/favicon.ico into /home/hbollon/Documents/Projects/igopher/cmd/igopher/gui/windows.syso
2021/03/03 11:04:56 Removing /home/hbollon/Documents/Projects/igopher/output/windows-amd64
2021/03/03 11:04:57 Creating /home/hbollon/Documents/Projects/igopher/output/windows-amd64
2021/03/03 11:04:57 Building for os windows and arch amd64 astilectron: 0.44.0 electron: 11.1.0
2021/03/03 11:04:57 Executing go build -ldflags -H "windowsgui" -X "igopher.AppName=IGopher" -X "igopher.BuiltAt=2021-03-03 11:04:57.026107371 +0100 CET m=+1213.948761138" -X "igopher.VersionAstilectron=0.44.0" -X "igopher.VersionElectron=11.1.0" -o /home/hbollon/Documents/Projects/igopher/output/windows-amd64/binary .
2021/03/03 11:05:11 Moving /home/hbollon/Documents/Projects/igopher/output/windows-amd64/binary to /home/hbollon/Documents/Projects/igopher/output/windows-amd64/IGopher.exe
❯ cd output/linux-amd64
❯ chmod +x IGopher
❯ ./IGopher
./IGopher: 2: Syntax error: newline unexpected
I run that on Ubuntu 20.04 LTS with Go 1.16 The Windows executable doesn't works too on Windows 10
Problem is you should be naming your package main
instead of igopher
if you're looking to create an executable binary (which is the case here). Therefore you'll need to replace package igopher
with package main
in root .go
files as well as remove the bind
key in your bundler.json
so that it generates files with main
package.
Let me know how it goes
I already have a main package in cmd/igopher/gui
, this is why I defined input_path
to this folder.
I can't refactor my root package as main because I have two version of my project that I must build independently, a GUI and a TUI which are located in cmd/
as main packages and I import my igopher
package inside them.
So, there is no way to use the bundler with this architecture?
If I were you, I'd do things this way:
main
package in cmd/
main
package in another folder with basically the content of this fileigopher
package at the rootThen you'd need to bundler the separate GUI main
package instead of the igopher
package.
Does that make sense?
Ok so I did that (I've pushed these changes to bundler branch) but it still doesn't work... It generated an .ar file again but this time with a size of ~800ko
With this bundler.json;
{
"app_name": "IGopher",
"icon_path_darwin": "cmd/igopher/gui/resources/favicon.icns",
"icon_path_linux": "cmd/igopher/gui/resources/favicon.png",
"icon_path_windows": "cmd/igopher/gui/resources/favicon.ico",
"input_path": "cmd/igopher/gui/",
"environments": [
{
"arch": "amd64",
"os": "darwin"
},
{
"arch": "amd64",
"os": "linux"
},
{
"arch": "amd64",
"os": "windows",
"env": {
"CC": "x86_64-w64-mingw32-gcc",
"CXX": "x86_64-w64-mingw32-g++",
"CGO_ENABLED": "1"
}
}
]
}
And this output:
❯ astilectron-bundler cc && astilectron-bundler
2021/03/03 17:10:14 Removing /tmp/astibundler/cache
2021/03/03 17:10:14 Bundling for environment darwin/amd64
2021/03/03 17:10:14 Binding data
2021/03/03 17:10:14 Removing /tmp/astibundler/bind
2021/03/03 17:10:14 Creating /tmp/astibundler/bind
2021/03/03 17:10:14 Creating /tmp/astibundler/bind/vendor_astilectron_bundler
2021/03/03 17:10:14 Creating /tmp/astibundler/cache
2021/03/03 17:10:14 Downloading https://github.com/asticode/astilectron/archive/v0.44.0.zip into /tmp/astibundler/cache/astilectron-0.44.0.zip
2021/03/03 17:10:14 astikit: sending GET request to https://github.com/asticode/astilectron/archive/v0.44.0.zip (1/1)
2021/03/03 17:10:15 Copying /tmp/astibundler/cache/astilectron-0.44.0.zip to /tmp/astibundler/bind/vendor_astilectron_bundler/astilectron.zip
2021/03/03 17:10:15 Downloading https://github.com/electron/electron/releases/download/v11.1.0/electron-v11.1.0-darwin-x64.zip into /tmp/astibundler/cache/electron-darwin-amd64-11.1.0.zip
2021/03/03 17:10:15 astikit: sending GET request to https://github.com/electron/electron/releases/download/v11.1.0/electron-v11.1.0-darwin-x64.zip (1/1)
2021/03/03 17:10:59 Copying /tmp/astibundler/cache/electron-darwin-amd64-11.1.0.zip to /tmp/astibundler/bind/vendor_astilectron_bundler/electron.zip
2021/03/03 17:10:59 Creating /tmp/astibundler/bind/resources
2021/03/03 17:10:59 Copying /home/hbollon/Documents/Projects/igopher/cmd/igopher/gui/resources to /tmp/astibundler/bind/resources
2021/03/03 17:11:00 Generating /home/hbollon/Documents/Projects/igopher/cmd/igopher/gui/bind_darwin_amd64.go
2021/03/03 17:11:02 Removing /home/hbollon/Documents/Projects/igopher/output/darwin-amd64
2021/03/03 17:11:02 Creating /home/hbollon/Documents/Projects/igopher/output/darwin-amd64
2021/03/03 17:11:02 Building for os darwin and arch amd64 astilectron: 0.44.0 electron: 11.1.0
2021/03/03 17:11:02 Executing go build -ldflags -X "main.AppName=IGopher" -X "main.BuiltAt=2021-03-03 17:11:02.722003145 +0100 CET m=+48.217573451" -X "main.VersionAstilectron=0.44.0" -X "main.VersionElectron=11.1.0" -o /home/hbollon/Documents/Projects/igopher/output/darwin-amd64/binary .
2021/03/03 17:11:06 Creating /home/hbollon/Documents/Projects/igopher/output/darwin-amd64/IGopher.app/Contents/MacOS
2021/03/03 17:11:06 Moving /home/hbollon/Documents/Projects/igopher/output/darwin-amd64/binary to /home/hbollon/Documents/Projects/igopher/output/darwin-amd64/IGopher.app/Contents/MacOS/IGopher
2021/03/03 17:11:06 Chmoding /home/hbollon/Documents/Projects/igopher/output/darwin-amd64/IGopher.app/Contents/MacOS/IGopher
2021/03/03 17:11:06 Creating /home/hbollon/Documents/Projects/igopher/output/darwin-amd64/IGopher.app/Contents/Resources
2021/03/03 17:11:06 Copying /home/hbollon/Documents/Projects/igopher/cmd/igopher/gui/resources/favicon.icns to /home/hbollon/Documents/Projects/igopher/output/darwin-amd64/IGopher.app/Contents/Resources/IGopher.icns
2021/03/03 17:11:06 Adding Info.plist to /home/hbollon/Documents/Projects/igopher/output/darwin-amd64/IGopher.app/Contents/Info.plist
2021/03/03 17:11:06 Bundling for environment linux/amd64
2021/03/03 17:11:06 Binding data
2021/03/03 17:11:06 Removing /tmp/astibundler/bind
2021/03/03 17:11:06 Creating /tmp/astibundler/bind
2021/03/03 17:11:06 Creating /tmp/astibundler/bind/vendor_astilectron_bundler
2021/03/03 17:11:06 Creating /tmp/astibundler/cache
2021/03/03 17:11:06 /tmp/astibundler/cache/astilectron-0.44.0.zip already exists, skipping download of https://github.com/asticode/astilectron/archive/v0.44.0.zip
2021/03/03 17:11:06 Copying /tmp/astibundler/cache/astilectron-0.44.0.zip to /tmp/astibundler/bind/vendor_astilectron_bundler/astilectron.zip
2021/03/03 17:11:06 Downloading https://github.com/electron/electron/releases/download/v11.1.0/electron-v11.1.0-linux-x64.zip into /tmp/astibundler/cache/electron-linux-amd64-11.1.0.zip
2021/03/03 17:11:06 astikit: sending GET request to https://github.com/electron/electron/releases/download/v11.1.0/electron-v11.1.0-linux-x64.zip (1/1)
2021/03/03 17:11:58 Copying /tmp/astibundler/cache/electron-linux-amd64-11.1.0.zip to /tmp/astibundler/bind/vendor_astilectron_bundler/electron.zip
2021/03/03 17:11:58 Creating /tmp/astibundler/bind/resources
2021/03/03 17:11:58 Copying /home/hbollon/Documents/Projects/igopher/cmd/igopher/gui/resources to /tmp/astibundler/bind/resources
2021/03/03 17:11:58 Generating /home/hbollon/Documents/Projects/igopher/cmd/igopher/gui/bind_linux_amd64.go
2021/03/03 17:12:01 Removing /home/hbollon/Documents/Projects/igopher/output/linux-amd64
2021/03/03 17:12:01 Creating /home/hbollon/Documents/Projects/igopher/output/linux-amd64
2021/03/03 17:12:01 Building for os linux and arch amd64 astilectron: 0.44.0 electron: 11.1.0
2021/03/03 17:12:01 Executing go build -ldflags -X "main.AppName=IGopher" -X "main.BuiltAt=2021-03-03 17:12:01.656438763 +0100 CET m=+107.152009074" -X "main.VersionAstilectron=0.44.0" -X "main.VersionElectron=11.1.0" -o /home/hbollon/Documents/Projects/igopher/output/linux-amd64/binary .
2021/03/03 17:12:01 Moving /home/hbollon/Documents/Projects/igopher/output/linux-amd64/binary to /home/hbollon/Documents/Projects/igopher/output/linux-amd64/IGopher
2021/03/03 17:12:01 Bundling for environment windows/amd64
2021/03/03 17:12:01 Binding data
2021/03/03 17:12:01 Removing /tmp/astibundler/bind
2021/03/03 17:12:01 Creating /tmp/astibundler/bind
2021/03/03 17:12:01 Creating /tmp/astibundler/bind/vendor_astilectron_bundler
2021/03/03 17:12:01 Creating /tmp/astibundler/cache
2021/03/03 17:12:01 /tmp/astibundler/cache/astilectron-0.44.0.zip already exists, skipping download of https://github.com/asticode/astilectron/archive/v0.44.0.zip
2021/03/03 17:12:01 Copying /tmp/astibundler/cache/astilectron-0.44.0.zip to /tmp/astibundler/bind/vendor_astilectron_bundler/astilectron.zip
2021/03/03 17:12:01 Downloading https://github.com/electron/electron/releases/download/v11.1.0/electron-v11.1.0-win32-x64.zip into /tmp/astibundler/cache/electron-windows-amd64-11.1.0.zip
2021/03/03 17:12:01 astikit: sending GET request to https://github.com/electron/electron/releases/download/v11.1.0/electron-v11.1.0-win32-x64.zip (1/1)
2021/03/03 17:12:44 Copying /tmp/astibundler/cache/electron-windows-amd64-11.1.0.zip to /tmp/astibundler/bind/vendor_astilectron_bundler/electron.zip
2021/03/03 17:12:44 Creating /tmp/astibundler/bind/resources
2021/03/03 17:12:44 Copying /home/hbollon/Documents/Projects/igopher/cmd/igopher/gui/resources to /tmp/astibundler/bind/resources
2021/03/03 17:12:44 Generating /home/hbollon/Documents/Projects/igopher/cmd/igopher/gui/bind_windows_amd64.go
2021/03/03 17:12:48 Running rsrc for icon /home/hbollon/Documents/Projects/igopher/cmd/igopher/gui/resources/favicon.ico into /home/hbollon/Documents/Projects/igopher/cmd/igopher/gui/windows.syso
2021/03/03 17:12:49 Removing /home/hbollon/Documents/Projects/igopher/output/windows-amd64
2021/03/03 17:12:49 Creating /home/hbollon/Documents/Projects/igopher/output/windows-amd64
2021/03/03 17:12:49 Building for os windows and arch amd64 astilectron: 0.44.0 electron: 11.1.0
2021/03/03 17:12:49 Executing go build -ldflags -H "windowsgui" -X "main.AppName=IGopher" -X "main.BuiltAt=2021-03-03 17:12:49.340632624 +0100 CET m=+154.836202936" -X "main.VersionAstilectron=0.44.0" -X "main.VersionElectron=11.1.0" -o /home/hbollon/Documents/Projects/igopher/output/windows-amd64/binary .
2021/03/03 17:12:55 Moving /home/hbollon/Documents/Projects/igopher/output/windows-amd64/binary to /home/hbollon/Documents/Projects/igopher/output/windows-amd64/IGopher.exe
Ok so I managed to create valid executables by moving bundler.json
inside cmd/igopher/gui
and removing input_path inside it.
But now when I execute it I have this error:
INFO[0000] astikit: starting worker... function=Info line=100
INFO[0000] astikit: stopping worker... function=Info line=100
FATA[0000] running bootstrap failed: restoring resources failed: checking resources failed: getting checksum of assets failed: getting checksum of resources/ failed: getting data from asset resources/ failed: Asset resources/ not found function=main line=73
It's not extracting resources and vendor folder...
Okay it's working !! There was just one error left on my side, I had defined "ResourcesPath" which was obviously causing problems :smile: Thanks for your help !
Hi ! Thanks for your amazing go-astilectron! I'm building an app with it who works like a charm! However, wanted to embed electron, astilectron and my ressources to my binary. So I migrated to go-astilectron-bootstrap to be able to use go-astilectron-bundler to build binaries for linux/macos/windows. Thanks to the demo application and the go-astilectron-bundler documentation, I think I managed to adapt the bundler with the architecture of my project. But when I run astilectron-bundler (from the root of my project), it runs without errors and generates the executables. But these don't work, moreover, the one for Linux is an .ar file ...
If you have any ideas of what i did wrong it will help me a lot! :smile:
My project structure looks like this:
And my bundler.json:
The output I get when I execute
astilectron-bundler cc && astilectron-bundler -c bundler.json
:You can find all my project here: https://github.com/hbollon/IGopher/tree/bundler On the dev branch, you can find the perfectly functional version of my program without the bootstrap or the bundler if necessary :smile:
I have Go 1.16