I'm not able to build an executable file of an Electron App
with the following command:
electron-packager . electron-tutorial-app --overwrite --asar=true --platform=linux --arch=x64 --prune=true --out=release-builds
The build file, which is a shared library file (application/x-sharedlib), is not executing on Ubuntu 18
. Instead, I'm getting the following error message when opening the file in Nautilus:
Could not display "electron-tutorial-app"
There is no application installed for "shared library" files. Do you want to search for an application to open this file?
[No] [Yes]
Is there any way around to do this?
TL;DR: the produced files are actually executables of a new format. There's nothing wrong with them. Nautilus/file managers mistakenly don't recognize them as executables. There are solutions, such as creating a *.desktop file to launch the application.
This phenomenon occurs as a side-effect of a change in how Electron builds Linux binaries. The commit 9294facf changed the binary format from ELF to PIE. The change is quite small and only affects a single file (BUILD.gn). The change has landed in Electron starting with version 4.0.0.
File managers utilize the file
command to decide what to do with a file (e.g. open an image viewer, a text editor or execute the file). file
cannot distinguish between shared libraries and PIE executables and therefore misclassifies PIE files (see the corresponding bug report).
Since the problem only exists for graphical file managers, you can simply run the executable from the terminal or from a script. This is somewhat involved for non-technical end users and not what the OP wants.
Wait for file
to recognize PIE as executable files. In turn, this will likely lead to file managers such as Nautilus to launch the PIEs correctly. It's not clear if or when this will happen. If it happens, it will likely only be included in future distro releases.
Create a desktop file to launch the application. This is a common way desktop applications are launched anyway.
Create a file called myapp.desktop
with the following contents.
[Desktop Entry]
Name=My Application
Exec=/path/to/binary
Terminal=false
Type=Application
StartupNotify=true
Encoding=UTF-8
Then, mark the desktop file executable by issuing chmod +x myapp.desktop
. Double clicking the file should launch the application as expected.
Further information
The corresponding discussion in the electron-packager project: https://github.com/electron-userland/electron-packager/issues/901. (Gist: This issue was not caused by electron-packager, look upstream)
The corresponding issue in the electron project is https://github.com/electron/electron/issues/15406. (Gist: they wanted to enable PIE on Linux. Not our bug, look upstream)
For Linux(Ubuntu):
Downgrade Electron package:
npm install [email protected] --save-dev
For global (If needed)
npm install -g [email protected]
Execute electron-packager command - for linux:
electron-packager . electron-tutorial-app --overwrite --asar --platform=linux --arch=all --prune=true --out=release-builds
This will result in 4 Linux folders(arch=all). Select a working executable according to your OS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With