asticode / go-astilectron-bundler

Bundle your Astilectron app with ease

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mac OSX .app file fails to open

radding opened this issue · comments

The executable in Content/MacOS/ runs fine, but the .app fails to open. I am using the bundler with this config:

  "app_name": "Courier",
  "icon_path_darwin": "assets/icon.icns",
  "icon_path_linux": "assets/icon.png",
  "icon_path_windows": "assets/icon.ico",
  "version_electron": "7.1.10",
  "version_astilectron": "0.41.0",
  "input_path": "./cmd/courier/",
  "resources_path": "../../assets/",
  "resources_bind_path": "resources/",
  "ldflags": {
    "X": [
      "github.com/shuttl-io/courier-cli/internal/buildvars.IsDevelopment=NO"
    ]
  },
  "ldflags_package": "github.com/shuttl-io/courier-cli/internal/buildvars",
  "environments": [
    {
      "arch": "amd64",
      "os": "darwin"
    },
    {
      "arch": "amd64",
      "os": "linux"
    },
    {
      "arch": "386",
      "os": "linux"
    },
    {
      "arch": "386",
      "os": "windows"
    },
    {
      "arch": "amd64",
      "os": "windows",
      "env": {
        "CC": "x86_64-w64-mingw32-gcc",
        "CXX": "x86_64-w64-mingw32-g++",
        "CGO_ENABLED": "1"
      }
    }
  ],
  "info_plist": {
    "CFBundlePackageType": "APPL",
    "CFBundleInfoDictionaryVersion": "6.0",
    "CFBundleIconFile": "Courier.icns",
    "CFBundleDisplayName": "Courier",
    "CFBundleExecutable": "Courier",
    "CFBundleIdentifier": "com.courierconfig.client",
    "LSUIElement": "NO",
    "LSMinimumSystemVersion": "10.11",
    "NSAppTransportSecurity": {
      "NSAllowsArbitraryLoads": true
    }
  }
}

Running Open gives me this error:
LSOpenURLsWithRole() failed with error -10810 for the file /Users/<>/Downloads/Courier.app

Looking up that error isn't much help:

Error -10810
Basically, it means that the Launch Services framework is misbehaving and is encountering errors when trying to launch an application. When you encounter this error message, it is probably best to restart the machine.

This happens on every Mac, not just this machine.

I am building on linux using my branch of the bundler here: https://github.com/shuttl-io/go-astilectron-bundler/tree/temp-branch

Is there any flags or anything I am missing?

Can you check out those issues and see if they're any help ?

Issue 1
Issue 2

Looking over those issues, one thing that stood out to me was notorizing the application. I don't understand too much about it, but would this be a potential issue?

Update: I tried to add logging in order to verify it wasn't something else, the executable doesn't even run (I have a log file that gets created first thing in my program, and nothing).

Looking over those issues, one thing that stood out to me was notorizing the application. I don't understand too much about it, but would this be a potential issue?

I think that may be an issue indeed.

Are you using relative paths in your app ?

In what sense? In someplaces I am, in others its relative to the EXE path

Could you try replacing your relative paths into absolute paths and see whether it fixes the problem? I remember having the same issue and fixing it by doing the exact same thing.

Notarizing isn't the issue, and neither is the relative file paths

Mmm it's really weird. Maybe you could try removing the info_plist key of your bundler.json and see whether this is causing the issue

I had this issue with and without the info_plist key unfortunately.

Maybe another piece of information: I am seeing similar issues with the .exe for windows. It works fine from the CMD prompt, but double click to launch doesn't work

@radding Try to move your app to your Applications Directory. Do not start it from ~/Downloads.

@radding Try to move your app to your Applications Directory. Do not start it from ~/Downloads.

@bogdanfinn I have tried that, same issue.

@radding
I also had several issues getting the macos app running.
I would suggest that you check the following things:

  • Check the whole application and all dependencies if they are loading files from the Filesystem by relative path (for me i had a dependency which did this)
  • Try to use the exact same setup as in the demo project. I mean regarding the directories / files (for example resources).
  • Try to bundle and run the demo app, does this work for you? Because then it might be related to your bundle config?

@bogdanfinn I have verified I am not loading files from the Filesystem by relative path.

For the second point, that is not possible as this is an exsiting CLI app with a GUI added on top

I will try the third point

@radding so i have the same setup. a cli app with a gui on top. And i did not use astilectron-bootstrap.
For me the issue was in my code.

@bogdanfinn Are you using Cobra for CLI parsing? I am debuging my code now and I have this theory that that may be my issue.

@radding no i use another library for my application.

Yea. Looks like that was it. The launcher caused Cobra to not recognize the application properly and caused it to not launch.

@radding how did you solve the issue? Because suddenly i have the same issue but not using Cobra.
On Windows everything still works and also the executable in Content/MacOS/ runs fine ...

Basically I just checked to see if the application was started in the terminal by using the pid of the parent. On mac OSX, if the app is started by launchd, then the pid is 1. So if the ppid is 1 then I start the gui directly

@radding
Okay solved my issue. I updated a dependency of my application and there was a change where a file was created by relative path.

As mentioned here: #81 (comment)
Fixing this solved my problem