Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NWJS 0.16.1 - Can not double click on the binary to run on Ubuntu #5287

Closed
cuongleqq opened this issue Sep 9, 2016 · 14 comments

Comments

@cuongleqq
Copy link

commented Sep 9, 2016

Hi,

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

nwjs012

Now I am using 0.16.1 and it shows like bellow

nwjs0161

And when I double click on the binary, it shows

nwjs0161doubeclick

So how do I make it so that people can double click to run?
Thanks for reading!

@rogerwang

This comment has been minimized.

Copy link
Member

commented Sep 9, 2016

I think this is a duplicate issue @ghostoy

@ghostoy

This comment has been minimized.

Copy link
Member

commented Sep 9, 2016

There was a discussion in mailing list: https://groups.google.com/d/topic/nwjs-general/2bnKU8dYZrA/discussion . You can write your own .desktop file to launch the app as in the discussion.

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.

@marckris

This comment has been minimized.

Copy link

commented Dec 1, 2016

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.

nautilus

@ghostoy

This comment has been minimized.

Copy link
Member

commented Dec 1, 2016

@marckris Here is my sample .desktop file and it works with Nautilus:

[Desktop Entry]
Name=My App
Exec=/path/to/nw
Terminal=false
Type=Application
@marckris

This comment has been minimized.

Copy link

commented Dec 1, 2016

@ghostoy I already tried that and it doesn't work as I mentioned earlier.
I'm on Ubuntu 16.04 with Nautilus 3.14.3. This is what I get when I double-click on MyApp.desktop

nautilus2

@marckris

This comment has been minimized.

Copy link

commented Dec 1, 2016

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.

@ghostoy

This comment has been minimized.

Copy link
Member

commented Dec 2, 2016

@marckris Try to set x (execute) permission for the desktop file by chmod a+x MyApp.desktop.

@marckris

This comment has been minimized.

Copy link

commented Dec 2, 2016

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.

@marckris

This comment has been minimized.

Copy link

commented Dec 2, 2016

Here is a side by side comparisson of NW I used last year with the one I use now.

nautilus3

@ghostoy

This comment has been minimized.

Copy link
Member

commented Dec 2, 2016

The error "There was an error launching the program" may be caused of using relative path to nw. You can use Exec=sh -c "$(dirname %k)/nw" instead of Exec=nw.

@marckris

This comment has been minimized.

Copy link

commented Dec 2, 2016

@ghostoy
Wow that works! It didn't occur to me to define Exec in such way.

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
because Exec simply calls sh to run MyApp.

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!
I consider my issue solved.

Just for a reference for those who come here in the future:
http://unix.stackexchange.com/questions/144422/getting-the-current-path-in-desktop-exec-command

Exec=bash -c '"$(dirname "$1")"/run.sh' dummy %k

There is an explanation there on how that works.

@rogerwang

This comment has been minimized.

Copy link
Member

commented Dec 2, 2016

@ghostoy it may be worth finding out why Chromium upstream sets it to application/x-sharedlib.

@marckris

This comment has been minimized.

Copy link

commented Dec 2, 2016

@rogerwang I agree. Although I'm not sure if that's the upstream. From a number of readings, it appears that there is nothing in ELF that tells whether this is an executable or shared library.

@ghostoy

This comment has been minimized.

Copy link
Member

commented Dec 21, 2016

The Chromium was linked with -pie to enable Address space layout randomization (ASLR). ASLR can prevent buffer overflow attacks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.