asticode / go-astilectron-bootstrap

Create a one-window application using Astilectron
MIT License
60 stars 37 forks source link

Bug on macOS while restoring assets on first launch #14

Closed aeddi closed 5 years ago

aeddi commented 5 years ago

Hello,

When I build my Electron App using astilectron-bootstrap and astilectron-bundler, I can open it normally with the computer I used to build it (double-click on myapp.app from the finder or using this command open myapp.app) but I can't from another computer.

After a little investigation, I realized that the problem occurred when the restoreResources function was called.

I got this error when it tries to remove resources:

removing /private/var/folders/yt/h63bwpcs5_3dwlv_8_mxgphw0000gn/T/AppTranslocat
ion/F1665C30-7AB9-4745-82BC-E8E06910032D/d/Berty.app/Contents/MacOS/resources f
ailed: read-only file system

Then the app crash.

If I manually launch the binary contained in the package ./myapp.app/Contents/MacOS/myapp, it works. The files are well decompressed in .myapp.app/Contents/MacOS/resource (not /private/var/...) then I can launch the application normally from the finder.

Signing the application with a production certificate doesn't solve the problem.

If you have an idea to solve the problem, I'll take it. :) I will continue to investigate and submit a PR to you if I find a solution.


macOS version: Mojave 10.14.3 astilectron-bootstrap version: latest (commit b321164) astilectron-bundler version: latest (commit 6b22eaf)

aeddi commented 5 years ago

Ok, actually, the problem comes from the fact that when you launch the application from the finder or the open command, a call to the os.Executable() function returns the wrong path, it returns the "AppTranslocation" path instead of the real binary path. So the initBaseDirectory doesn't work correctly in this case (and I don't know if that can be a problem elsewhere in the code).

I have just seen by inquiring that since macOS 10.12, Gatekeeper Path Randomization has become mandatory for application distributed outside the Store and from what I see, the problem doesn't appear on the machine that was used to build the application.

Well, I'm starting to look for a solution again.

aeddi commented 5 years ago

Apparently the best way to get around the path randomization is to force the user to put the .app in the Applications folder.

So problem solved.

asticode commented 5 years ago

Good to know, thanks for sharing!