asticode / go-astilectron-bundler

Bundle your Astilectron app with ease
MIT License
127 stars 67 forks source link

Mac OSX .app file fails to open #81

Open radding opened 3 years ago

radding commented 3 years ago

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?

asticode commented 3 years ago

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

Issue 1 Issue 2

radding commented 3 years ago

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?

radding commented 3 years ago

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

asticode commented 3 years ago

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 ?

radding commented 3 years ago

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

asticode commented 3 years ago

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.

radding commented 3 years ago

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

asticode commented 3 years ago

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

radding commented 3 years ago

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

bogdanfinn commented 3 years ago

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

radding commented 3 years ago

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

@bogdanfinn I have tried that, same issue.

bogdanfinn commented 3 years ago

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

radding commented 3 years ago

@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

bogdanfinn commented 3 years ago

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

radding commented 3 years ago

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

bogdanfinn commented 3 years ago

@radding no i use another library for my application.

radding commented 3 years ago

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

bogdanfinn commented 3 years ago

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

radding commented 3 years ago

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

bogdanfinn commented 3 years ago

@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: https://github.com/asticode/go-astilectron-bundler/issues/81#issuecomment-726212577 Fixing this solved my problem