Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Windows: Unable to run myprog.exe: astilectron does not unzip #20

Open
pbm opened this issue Jun 7, 2021 · 9 comments
Open

Windows: Unable to run myprog.exe: astilectron does not unzip #20

pbm opened this issue Jun 7, 2021 · 9 comments
Assignees
Labels

Comments

@pbm
Copy link

pbm commented Jun 7, 2021

I've inherited an old project from a developer (that no longer works with us) and need to fix a bug, but I am unable to run the (unmodified) program from any of my builds.

Symptoms (seen on both Windows 10 and Windows Server 2019):

  1. I use astilectron-bundler.exe to build myprog.exe
  2. I double click on myprog.exe: "nothing" happens

If I look in my user's ...\AppData\MyProg\vendor directory, I see astilectron-v0.48.0.zip and status.json (which is empty: {}).

If I run the last version of the program the original developer delivered, then in the ...\AppData\MyProg\vendor directory, I see

  • astilectron/
  • astilectron-v0.32.0.zip
  • electron-windows-386/
  • electron-windows-386-v4.0.1.zip
  • status.json

status.json has {"astilectron":{"version":"0.32.0"},"electron":{"windows-386":{"version":"4.0.1"}}}

It looks like something breaks trying to unzip the astilectron zip file, but I can't seem to find any error messages or system events that indicate why.

I tried pinning the astilectron version to 0.32.0 by setting version_astilectron in bundler.json, but that seems to be ignored and we get 0.48.0 instead.

Is there some way to turn on more logging or debugging output? I added logging to my part of the app, but I only see the log entries up until the time that bootstrap.Run(...) is called.

@asticode asticode self-assigned this Jun 7, 2021
@asticode
Copy link
Owner

asticode commented Jun 7, 2021

I see 2 ways to get more info:

  1. Bundle your app with the show_windows_console set to true in your bundler.json
  2. Run your binary in the terminal

Let me know

@pbm
Copy link
Author

pbm commented Jun 7, 2021

Hi,

Thanks for the quick reply, I appreciate it.

I added "show_windows_console": true, to bundler.json, rebuilt and ran from the terminal. I got no output in the terminal, and the results were the same.

One new thing I noticed. I've set version_astilectron to 0.32.0 in bundler.json but even though the file in the user's ...\AppData\MyProg\vendor directory is astilectrion-v0.48.0, if I look inside the zip file, I see an astilectron-v0.32.0 folder inside the zip. Not sure if the name mismatch is causing problems or not.

@asticode
Copy link
Owner

asticode commented Jun 8, 2021

I added "show_windows_console": true, to bundler.json, rebuilt and ran from the terminal. I got no output in the terminal, and the results were the same.

Is the Logger set in your bootstrap.Options?

Not sure if the name mismatch is causing problems or not.

This is clearly a problem. I'd be you, I'd try removing ...\AppData\MyProg and try running the binary from scratch.

@pbm
Copy link
Author

pbm commented Jun 8, 2021

Good news: I think I have something running, but I also think there is a bug in passing version_astilectron from bundler.json into the rest of the astilectron code.

Details

Is the Logger set in your bootstrap.Options?

Sorry, I missed that option. I set the logger, cleared my ...\AppData\* and re-ran. Here is the output (the first line is a logger output from my main() func):

$ MyProg\ Setup\ v2.5.exe
2021/06/08 15:35:25 === registration-main.go: Starting...
2021/06/08 15:35:25 astikit: starting worker...
2021/06/08 15:35:25 Resources folder doesn't exist, restoring resources...
2021/06/08 15:35:25 Removing C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\resources
2021/06/08 15:35:25 Restoring resources in C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\resources
2021/06/08 15:35:25 Starting...
2021/06/08 15:35:25 Provisioning...
2021/06/08 15:35:25 Provisioning Astilectron...
2021/06/08 15:35:25 Removing directory C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\astilectron
2021/06/08 15:35:25 Disembedding vendor_astilectron_bundler\astilectron.zip into C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\astilectron-v0.41.0.zip...
2021/06/08 15:35:25 Creating C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor
2021/06/08 15:35:25 Creating C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\astilectron-v0.41.0.zip
2021/06/08 15:35:25 Disembedding vendor_astilectron_bundler\astilectron.zip
2021/06/08 15:35:25 Copying disembedded data to C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\astilectron-v0.41.0.zip
2021/06/08 15:35:25 Creating directory C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\astilectron
2021/06/08 15:35:25 Unzipping C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\astilectron-v0.41.0.zip\astilectron-0.41.0 into C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\astilectron
2021/06/08 15:35:25 Removing C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\astilectron...
2021/06/08 15:35:25 Closing...
2021/06/08 15:35:25 astikit: stopping worker...

After running this, I still see only two items in the vendor directory:

  • astilectron-v0.41.0.zip
  • status.json

So it seems the unzip is not working, but no error logged, and then bundler simply exits at that point (before disembedding and unzipping electron). I looked inside the zip file and saw the name mismatch (the contents of the zip file were astilectron-v0.32.0, not v0.41.0). So I tried these experiments:

  1. removed version_astilectrion from bundler.json: This time there was still the name mismatch, but the contents of the zip file were v0.48.0 while the name of the zip file was v0.41.0
  2. I put "version_astilectron": "0.41.0", in the bundler.json file, and this time the whole thing ran fine (log output below). So this case the zip file name and the zip contents aligned.
$ MyProg\ User\ Setup\ v2.5.exe
2021/06/08 16:01:06 === registration-main.go: Starting...
2021/06/08 16:01:06 astikit: starting worker...
2021/06/08 16:01:06 Resources folder doesn't exist, restoring resources...
2021/06/08 16:01:06 Removing C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\resources
2021/06/08 16:01:06 Restoring resources in C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\resources
2021/06/08 16:01:07 Starting...
2021/06/08 16:01:07 Provisioning...
2021/06/08 16:01:07 Provisioning Astilectron...
2021/06/08 16:01:07 Removing directory C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\astilectron
2021/06/08 16:01:07 Disembedding vendor_astilectron_bundler\astilectron.zip into C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\astilectron-v0.41.0.zip...
2021/06/08 16:01:07 Creating C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor
2021/06/08 16:01:07 Creating C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\astilectron-v0.41.0.zip
2021/06/08 16:01:07 Disembedding vendor_astilectron_bundler\astilectron.zip
2021/06/08 16:01:07 Copying disembedded data to C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\astilectron-v0.41.0.zip
2021/06/08 16:01:07 Creating directory C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\astilectron
2021/06/08 16:01:07 Unzipping C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\astilectron-v0.41.0.zip\astilectron-0.41.0 into C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\astilectron
2021/06/08 16:01:07 Provisioning Electron...
2021/06/08 16:01:07 Removing directory C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\electron-windows-386
2021/06/08 16:01:07 Disembedding vendor_astilectron_bundler\electron.zip into C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\electron-windows-386-v7.1.10.zip...
2021/06/08 16:01:07 Creating C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor
2021/06/08 16:01:07 Creating C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\electron-windows-386-v7.1.10.zip
2021/06/08 16:01:07 Disembedding vendor_astilectron_bundler\electron.zip
2021/06/08 16:01:07 Copying disembedded data to C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\electron-windows-386-v7.1.10.zip
2021/06/08 16:01:07 Creating directory C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\electron-windows-386
2021/06/08 16:01:07 Unzipping C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\electron-windows-386-v7.1.10.zip into C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\electron-windows-386
2021/06/08 16:01:10 System doesn't require finshing provisioning electron, moving on...
2021/06/08 16:01:10 Listening...
2021/06/08 16:01:10 Executing...
2021/06/08 16:01:10 Starting cmd C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\electron-windows-386\electron.exe C:\Users\Administrator\AppData\Roaming\MyProg Setup v2.5\vendor\astilectron\main.js 127.0.0.1:65238 false
2021/06/08 16:01:13 Stdout says:
2021/06/08 16:01:13 Astilectron says: {"name":"app.event.ready","targetID":"app","displays":{"all":[{"id":2528732444,"bounds":{"x":0,"y":0,"width":1440,"height":900},"workArea":{"x":0,"y":0,"width":1440,"height":860},"size":{"width":1440,"height":900},"workAreaSize":{"width":1440,"height":860},"scaleFactor":1,"rotation":0,"touchSupport":"unknown"}],"primary":{"id":2528732444,"bounds":{"x":0,"y":0,"width":1440,"height":900},"workArea":{"x":0,"y":0,"width":1440,"height":860},"size":{"width":1440,"height":900},"workAreaSize":{"width":1440,"height":860},"scaleFactor":1,"rotation":0,"touchSupport":"unknown"}},"supported":{"notification":true}}
2021/06/08 16:01:13 Sending to Astilectron: {"name":"window.cmd.create","targetID":"1","sessionId":"2","url":"c:\\Users\\Administrator\\AppData\\Roaming\\MyProg Setup v2.5\\resources\\app\\index.html","windowOptions":{"center":true,"height":600,"icon":"C:\\Users\\Administrator\\AppData\\Roaming\\MyProg Setup v2.5\\resources\\icon.png","title":"MyProg Setup v2.5","width":600}}
2021/06/08 16:01:14 Astilectron says: {"name":"window.event.focus","targetID":"1"}
2021/06/08 16:01:16 Astilectron says: {"name":"window.event.did.finish.load","targetID":"1"}
2021/06/08 16:01:16 Sending to Astilectron: {"name":"menu.cmd.create","targetID":"3","menu":{"id":"3","items":[{"id":"4","options":{},"rootId":"app","submenu":{"id":"5","items":[{"id":"6","options":{"accelerator":"Control+d","label":"Debug","type":"checkbox"},"rootId":"app"}],"rootId":"app"}}],"rootId":"app"}}
2021/06/08 16:01:16 Astilectron says: {"name":"menu.event.created","targetID":"3"}
2021/06/08 16:01:16 astikit: worker is now waiting...
2021/06/08 16:01:16 Astilectron says: {"name":"window.event.message","targetID":"1","message":{"name":"event.setToken","payload":{}},"callbackId":"1"}
2021/06/08 16:01:16 Sending to Astilectron: {"name":"window.cmd.message.callback","targetID":"1","callbackId":"1","message":{"name":"event.setToken.callback","payload":"empty"}}
2021/06/08 16:05:27 Astilectron says: {"name":"window.event.blur","targetID":"1"}

(Note: My program was still running when I captured this log file, so we don't see it exit).

Thanks for your help, I really appreciate it. If you need any help on tracking down the version mismatch bug, let me know.

@pbm
Copy link
Author

pbm commented Jun 8, 2021

One more update. I checked my ...\AppData directory, and even though I had "version_electron": "4.0.1", in the bundler.json, the actual version unpacked into the vendor dir was Electron 7.1.10.

@pbm
Copy link
Author

pbm commented Jun 8, 2021

Final comment: Looking back to the root cause: I think that with all defaults (i.e., no version_astilectron and no version_electron in the bundler.json), the zip file ended up with mismatched contents (as shown in experiment 2 above: astilectron-v0.41.0.zip but with contents of astilectron-v0.48.0 inside the zipfile). So when I did my first build, and "nothing happened", I think it was due to this mismatch. I only started playing with the versions in bundler.json while trying to fix the original problem.

@asticode
Copy link
Owner

asticode commented Jun 9, 2021

First off, thanks for taking the time to investigate all this. What you're experiencing is really weird. Can you tell me which version you're using for astilectron and astilectron-bundler?

@asticode
Copy link
Owner

asticode commented Jun 9, 2021

Also, if you don't see any error in logs, my guess is that it's because your program doesn't process the error of bootstrap.Run and doesn't log it. It's not logged automatically.

@pbm
Copy link
Author

pbm commented Jun 9, 2021

First off, thanks for taking the time to investigate all this. What you're experiencing is really weird. Can you tell me which version you're using for astilectron and astilectron-bundler?

This is what I have under $GOPATH/pkg/mod/github.com/asticode:

I'm not sure which version of bundler got put into $GOPATH/bin.

Here is my bundler.json, in case that helps:

{
  "app_name": "MyProg Setup v2.5",
  "icon_path_windows": "resources/icon.ico",
  "output_path": "registration",
  "version_electron": "4.0.1",
  "version_astilectron": "0.41.0",
  "show_windows_console": true,
  "environments": [
    {"arch": "386", "os": "windows"},
    {
      "arch": "amd64",
      "os": "windows",
      "env": {
        "CC": "x86_64-w64-mingw32-gcc",
        "CXX": "x86_64-w64-mingw32-g++",
        "CGO_ENABLED": "1"
      }
    }
  ]
}

Also, if you don't see any error in logs, my guess is that it's because your program doesn't process the error of bootstrap.Run and doesn't log it. It's not logged automatically.

You are correct, my code was not capturing the return value. I've fixed that, but now that things are working for me, I'm not getting an error anymore.

Thanks for your help

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants