I'm building an electron app and I need GraphicsMagick. The documentation suggest that you have to download and install the program itself before using it with node.js. So just installing the npm package is not enough.
How do I do it then? Do I actually have to have my Electron app download binaries (or bundle it with binaries) and then install the program on the first app launch in order to be able to use it?
It doesn't even support CLI commands like for example ffmpeg does, so I cannot just bundle the binaries and execute commands like gm.exe convert test.jpg
I'd say yes, you have to bundle the binaries together with your app, if you don't want to distribute your app via a package repository or require your user to install GraphicsMagick previously.
It does support CLI commands like gm.exe convert test.jpg. If your using electron-builder for packaging, you must add a configuration to prevent the binaries from being asar-packed:
"build": {
"asarUnpack": [
"path/to/your/GraphicsMagick/binary/**"
],
From electron you can call the program e.g. with
const child_process = require('child_process')
child_process.execFile('relative/path/to/your/gm.exe', ['version'],
(error, stdout, stderr) => {
console.log(stdout)
} )
You can download the windows binaries e.g. from the sourceforge host. After installing those binaries you have to copy the installed folder to your app.
Related
When installing Electron on my company's computer, I have some issues regarding certs and other firewall problems. Because of that, I need to skip the download of the binaries during installation of the project dependencies.
There is a section on the doc, which tells you how to download the binaries, but I could't find how to install it.
I tried to unzip it on my home/.electron folder, which resulted nothing.
Is there a way to properly install this binaries manually?
I have an electron application that has the following dependencies:
ffmpeg
libmagic
gdbm
Currently, I use Homebrew and run brew install ffmpeg etc. upon startup of the app.
However, this is terrible for distribution. Is there a way to distribute these dependencies packaged alongside my application so that the end user doesn't have to have Homebrew or deal with installation errors? I'm distributing my app using electron-packager to create a Desktop Mac app.
I gave the specific dependencies just for context -- hopefully there is a solution that would work with any generic dependency?
It is possible with dynamic linking
use https://www.npmjs.com/package/ffmpeg-static
Example Usage
Returns the path of a statically linked ffmpeg binary on the local filesystem.
var pathToFfmpeg = require('ffmpeg-static');
console.log(pathToFfmpeg);
/Users/j/playground/node_modules/ffmpeg-static/ffmpeg
check https://discuss.atom.io/t/information-about-bundled-ffmpeg/28456/6
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.
Analysis
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).
Solutions
Run from terminal
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 upstream fix
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.
Use a desktop file
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 electron#3.1.6 --save-dev
For global (If needed)
npm install -g electron#3.1.6
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.
This is an issue when electron-packager is used to package a Linux app with Electron version 4.0.x, whereas there was no problem with previous Electron versions, such as 3.1.x.
For some reason, in Electron 4.0.x, the produced app file is a shared library instead of an executable.
From a Terminal window, running the file command on the app file path gives:
ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically
linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0,
BuildID[sha1]=b9e8ba37118dad1bf605affef41026f813215bc6, stripped
while it used to be:
ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically
linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32,
stripped
Fortunately, it is still possible, albeit cumbersome, to run the app by launching it from a Terminal window, for instance by dragging the app file icon onto the terminal prompt, then typing Enter.
I was wondering, how can I start to write an Electron app using the Hyper.js sources?
I am new to both Electron and Hyper, and watched a few videos on building an Electron app. But I can't quite figure out how to start the Hyper app. For instance, which is the "main" file in the sources?
Alright, after more reading and getting familiar with Node.js and Electron apps, the following procedure works:
git clone https://github.com/zeit/hyper
cd hyper
npm install
A lot of packages will be installed in a subdirectory called node_modules, then:
yarn run dev
And (in a separate terminal window):
yarn rup app
This will open an Electron app similar to the original one built by Hyper.
I write a jailbroken app using iOSOpenDev which can play audio in background when a timer fires.
When I use iOSOpenDev to build a .deb package, scp it to my iphone and install it using iFile, it works fine. But when I extract the .app to fold ~/temp, control file to ~/temp/DEBIAN/ , build a .deb package using command dpkg-deb -b ~/temp ~/myapp.deb, install and run it. It won't play music in background untill I bring it back to foreground.
Did I miss something when building the package?
There is no need to use scp and iFile.
With iOSOpenDev's command-line tool iosod there are commands to perform what you're trying to do:
iosod build: Builds a Debian package (does not require dpkg).
iosod install: Installs a Debian package on an iDevice.
There are even commands to remove and purge packages from an iDevice (iosod remove, iosod purge). To see all commands provided, in Terminal type iosod.
I should not only use terminal when building package but also to extracting file, then we can avoid the Finder adding some files, such as .DS_Store, we don't need.