takluyver / nbopen

Open a Jupyter notebook in the best available server
BSD 3-Clause "New" or "Revised" License
304 stars 58 forks source link

nbopen.desktop:There was an error launching the application #23

Open cardosan opened 8 years ago

cardosan commented 8 years ago

In linux mint 17.2 nbopen AwesomeNotebook.ipynb open my notebook but, after integrating it on the file manager (i.e. just running ./xdg-install.sh), clicking on nbopen.desktop I get 'There was an error launching the application' and obviously also double clicking .ipynb files does not work. Any idea on how to solve it? thanks

takluyver commented 8 years ago

Sigh that has to be one of the least helpful error messages ever.

There's a little script in this answer that should let you launch a .desktop file from a terminal. Can you try that on nbopen.desktop and see if it gives you any more useful error message?

cardosan commented 8 years ago

yes, indeed very cryptic error message :) I tried but do not think will be very useful ....it just ask for a filename to pass:

`grep '^Exec' nbopen.desktop | tail -1 | sed 's/^Exec=//' | sed 's/%.//' & [1] 4111 giuseppec@giuseppec-Latitude-E6530 ~/Downloads/nbopen-master $ usage: nbopen [-h] filename nbopen: error: the following arguments are required: filename`

that just passing the filename works : `grep '^Exec' nbopen.desktop | tail -1 | sed 's/^Exec=//' | sed 's/%.//' my_file.ipynb &^C`

takluyver commented 8 years ago

No, sorry, I meant this script from the linked answer:

#!/usr/bin/python

from gi.repository import Gio
import sys 

def main(myname, desktop, *uris):
    launcher = Gio.DesktopAppInfo.new_from_filename(desktop)
    launcher.launch_uris(uris, None)

if __name__ == "__main__":
    main(*sys.argv)

The grep/sed pipeline you used roughly reimplements what the desktop environment is supposed to do to load the desktop file - but it's not doing what it's supposed to. The Python script above should try to use the Gtk machinery to load the desktop file, which might reveal what it's doing wrong.

Alternatively, the issue might be in setting up the file association with .ipynb. I've had trouble with that before. Can you look at a notebook file in your file manager and see if it's associated with any application?

cardosan commented 8 years ago

I could not l launch yet the script cause I had prob with gi (I guess is due to the fact that I am using conda as default python) and did not have time so far to check of to solve this but can tell you that for sure I do not see any association with ipynb file in the mimelist.apps file (I guess should find something like application/x-ipynb+json)

takluyver commented 8 years ago

Yeah, you probably need to run the script with your default system Python, /usr/bin/python.

I think the mimelist.apps is for setting default applications - the desktop file and mime package it sets up should be enough for the desktop environment to connect ipynb files with nbopen. But I've had some trouble with the file association before, so try adding it to mimeapps.lst manually and see if that fixes anything.

cardosan commented 8 years ago

so I ran the script in my default system and it ask me for the file name

/usr/bin/python nbopen_test.py nbopen.desktop Untitled.ipynb giuseppec@giuseppec-Latitude-E6530 ~/Downloads/nbopen-master $ usage: nbopen [-h] filename nbopen: error: the following arguments are required: filename I also added application/x-ipynb+json=nbopen.desktop to the mimeapps.list manually (was not there) but no success :S

P.S: hope I did not make any mistake again, I am not an experienced programmer....in true I am not a programmer at all :)

takluyver commented 8 years ago

OK, I get that as well, even though double clicking on an ipynb file works for me.

I also tried replacing launch_uris() in that script with launch(), but then I get a segfault, so that's probably not it either. I don't know what else to try for debugging it :-S.

linuxrider commented 8 years ago

I cloned the repo and did the install with ./xdg-install.sh. Then I had the same message as in the heading. This was caused because the installer placed the nopen script in the /.local/bin dir which was not include in the .profile file. After adding this to path variable the .desktop file works just fine.

takluyver commented 8 years ago

@linuxrider that makes sense, but I think it's a different issue to what @cardosan was seeing, because they reported that the nbopen command worked.

Unfortunately I don't think there's any per-user location on $PATH by default. I guess we could make the installer add a line to ~/.profile, like:

PATH="$HOME/.local/bin:$PATH"