SublimeText / LaTeXTools

LaTeX plugin for Sublime Text
https://latextools.readthedocs.io/
2k stars 364 forks source link

Can not launch okular installed with Flatpack, even with an alias added to .bashrc #1481

Closed Gabriel-p closed 4 years ago

Gabriel-p commented 4 years ago

I've installed Okular via Flathub (https://flathub.org/apps/details/org.kde.okular), and then I added the following alias to my .bashrc file:

alias okular='flatpak run org.kde.okular'

and also to my .zshrc file. This works fine, and I am able to launch Okular via terminal with the okular command.

But LatexTools is not able to launch Okular after compiling the PDF (which it did just fine with the old version installed through apt-get). The console shows this error:

Finished normally
0
False True True
Jump to:  266 45
<class '_latextools_okular_viewer.OkularViewer'>
Running "ps xv"
['ps', 'xv'] None
Running "okular --unique --noraise"
['okular', '--unique', '--noraise'] None
Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 1082, in run_
    return self.run(edit, **args)
  File "/home/gabriel/.config/sublime-text-3/Packages/LaTeXTools/jumpToPDF.py", line 168, in run
    viewer.forward_sync(pdffile, srcfile, line, col, keep_focus=keep_focus)
  File "/home/gabriel/.config/sublime-text-3/Packages/LaTeXTools/viewers/okular_viewer.py", line 40, in forward_sync
    self._ensure_okular()
  File "/home/gabriel/.config/sublime-text-3/Packages/LaTeXTools/viewers/okular_viewer.py", line 36, in _ensure_okular
    self._run_okular(**kwargs)
  File "/home/gabriel/.config/sublime-text-3/Packages/LaTeXTools/viewers/okular_viewer.py", line 19, in _run_okular
    external_command(command, use_texpath=False)
  File "/home/gabriel/.config/sublime-text-3/Packages/LaTeXTools/latextools_utils/external_command.py", line 222, in external_command
    cwd=cwd
  File "./python3.3/subprocess.py", line 819, in __init__
  File "./python3.3/subprocess.py", line 1448, in _execute_child
FileNotFoundError: [Errno 2] No such file or directory: 'okular'
msiniscalchi commented 4 years ago

I'm guessing ST does not read .bashrc, so you need to create a script somewhere on your path that runs "flatpak run org.kde.okular" and is called "okular"

On Fri, Jul 31, 2020 at 4:24 PM Gabriel Perren notifications@github.com wrote:

I've installed Okular via Flathub ( https://flathub.org/apps/details/org.kde.okular), and then I added the following alias to my .bashrc file:

alias okular='flatpak run org.kde.okular'

and also to my .zshrc file. This works fine, and I am able to launch Okular via terminal with the okular command.

But LatexTools is not able to launch Okular after compiling the PDF (which it did just fine with the old version installed through apt-get). The console shows this error:

Finished normally 0 False True True Jump to: 266 45 <class '_latextools_okular_viewer.OkularViewer'> Running "ps xv" ['ps', 'xv'] None Running "okular --unique --noraise" ['okular', '--unique', '--noraise'] None Traceback (most recent call last): File "/opt/sublime_text/sublimeplugin.py", line 1082, in run return self.run(edit, args) File "/home/gabriel/.config/sublime-text-3/Packages/LaTeXTools/jumpToPDF.py", line 168, in run viewer.forward_sync(pdffile, srcfile, line, col, keep_focus=keep_focus) File "/home/gabriel/.config/sublime-text-3/Packages/LaTeXTools/viewers/okular_viewer.py", line 40, in forward_sync self._ensure_okular() File "/home/gabriel/.config/sublime-text-3/Packages/LaTeXTools/viewers/okular_viewer.py", line 36, in _ensure_okular self._run_okular(kwargs) File "/home/gabriel/.config/sublime-text-3/Packages/LaTeXTools/viewers/okular_viewer.py", line 19, in _run_okular external_command(command, use_texpath=False) File "/home/gabriel/.config/sublime-text-3/Packages/LaTeXTools/latextools_utils/external_command.py", line 222, in external_command cwd=cwd File "./python3.3/subprocess.py", line 819, in init File "./python3.3/subprocess.py", line 1448, in _execute_child FileNotFoundError: [Errno 2] No such file or directory: 'okular'

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/SublimeText/LaTeXTools/issues/1481, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFDKBJTZ2YFT7JTDGTVNN3R6MZCHANCNFSM4PQ5P3GA .

-- Marciano Siniscalchi Economics Department, Northwestern University http://faculty.wcas.northwestern.edu/~msi661

ig0774 commented 4 years ago

As I recall, Okular was actually the software I used to test the Command Viewer, which you can read about in the docs. The example at the bottom of the page should give you some idea about how to use it.

Gabriel-p commented 4 years ago

@ig0774 Okular does work without issues if I install it via sudo apt install okular. The problem is with the flathub installation of Okular. Then ST+LateXTools does not seem to be able to find it, even if an alias is added to .bashrc.

Gabriel-p commented 4 years ago

Managed to fix it using:

// ------------------------------------------------------------------
// Viewer settings
// ------------------------------------------------------------------
    // OPTION: "viewer"
    // Specifies which viewer to use
    "viewer": "command",

    // OPTION: "viewer_settings"
    "viewer_settings": {
        // Platform-specific settings:
        "linux" : {
            // See README or third-party documentation
            "view_command": "flatpak run org.kde.okular"
        }
    }