Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
NWJS 0.16.1 - Can not double click on the binary to run on Ubuntu #5287
I am trying to build my app for linux. When I used 0.12, the nw binary shown this way and let me double click on it to run
Now I am using 0.16.1 and it shows like bellow
And when I double click on the binary, it shows
So how do I make it so that people can double click to run?
There was a discussion in mailing list: https://groups.google.com/d/topic/nwjs-general/2bnKU8dYZrA/discussion . You can write your own
This issue seems to be related to http://bugs.gw.com/view.php?id=404. When Nautilus file manager opening nw, it detected it as shared library (application/x-sharedlib), rather than executable (application/x-executable). So it refused to execute it.
Switching from nwjs-community/nw-builder#401
I have tried using a .desktop file with no luck. When I double click on it Nautlius refuses to run it with a message "Untrusted application launcher. The application launcher "MyApp.desktop" has not been marked as trusted. If you do not know the source of this file, launching it may be unsafe".
My only solution was to rename MyApp (without extension) to MyApp.sh but I'm not sure if this is the proper way to do it.
Perhaps I forgot to mention that the app is distributed on CD and run directly from the CD by double-clicking MyApp on Linux, MyApp.app on OSx and MyApp.exe on Windows, thus not installed on host computer. I've done this last year for the same client but I can't recall what version of nw or node, but it was on december 11 using the latest versions. Although Linux is not in the requirements, it is a bonus so I need it to work.
I have read that too in a number of places and it is not working. When you set the executable bit, which you should, Nautilus (or any application runner doing it), the message is something like 'There was an error launching the program'. After 3 days searching, I'm pretty certain that there is a bug somewhere.
I have create an alternative with Electron and the electron-packager module works correctly. I'm not sure how it does it but Nautilus interpret the executable it produces as application/x-executable instead of application/x-sharedlib (as produced by nw-builder). I don't need a .desktop file. All I need to do is double click on it. Which BTW was also the case with nw-builder when I used it last year.
I think it has to do with how they build the Electron executable. As nw-builder, electron-packager also downloads Electron executable according to the platform we are building. Somehow Electron has managed to make their executables interpreted as application/x-executable. Probably has to do with the ELF header as I read somewhere.
If you notice when you download NW.js their executable is interpreted as application/x-sharedlib. This was not the case last year. Since I always run it from a terminal, it was not apparent to me.
I think that is practically the same, although yours is cleaner, with my renaming MyApp to MyApp.sh without the need to create a .desktop file as I mentioned in nwjs-community/nw-builder#401
What is suprising to me is that sh can actually run an executable. All these years I use sh to run shell scripts without even thinking about it. Then I remember bash -c
Thank you so much!
Just for a reference for those who come here in the future:
Exec=bash -c '"$(dirname "$1")"/run.sh' dummy %k
There is an explanation there on how that works.