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

Error that could not launch the viewer on Windows 11 #32

Open
leanhdung1994 opened this issue Jun 2, 2024 · 15 comments
Open

Error that could not launch the viewer on Windows 11 #32

leanhdung1994 opened this issue Jun 2, 2024 · 15 comments

Comments

@leanhdung1994
Copy link

leanhdung1994 commented Jun 2, 2024

I am using:

  • Windows 11 Pro version 23H2 and build 22631.3593.
  • Neovim verison 0.10.0.

My init.lua (for Windows as suggested by @andregpss in his comment) is the following:

require "paq" {
    "savq/paq-nvim";
    "frabjous/knap";
}

-- set shorter name for keymap function
local kmap = vim.keymap.set

-- F5 processes the document once, and refreshes the view
kmap({ 'n', 'v', 'i' },'<F5>', function() require("knap").process_once() end)

-- F6 closes the viewer application, and allows settings to be reset
kmap({ 'n', 'v', 'i' },'<F6>', function() require("knap").close_viewer() end)

-- F7 toggles the auto-processing on and off
kmap({ 'n', 'v', 'i' },'<F7>', function() require("knap").toggle_autopreviewing() end)

-- F8 invokes a SyncTeX forward search, or similar, where appropriate
kmap({ 'n', 'v', 'i' },'<F8>', function() require("knap").forward_jump() end)

local gknapsettings = {
    texoutputext = "pdf",
    textopdf = "pdflatex -interaction=batchmode -halt-on-error -synctex=1 %docroot%",
    textopdfviewerrefresh = "none",
    textopdfviewerlaunch = "sioyek --inverse-search \"nvim --headless -es\"  --new-window %outputfile%",
    textopdfviewerrefresh = "none",
     textopdfforwardjump = "sioyek --inverse-search \"nvim --headless -es\" --reuse-window --forward-search-file %srcfile% --forward-search-line %line% %outputfile%",   
    textopdfshorterror = "A=%outputfile% ; LOGFILE=\"${A%.pdf}.log\"" }

    vim.g.knap_settings = gknapsettings

I have a tex file C:\Users\Akira\Documents\LaTex\test.tex and open it in Neovim by :e C:\Users\Akira\Documents\LaTex\test.tex:

image

I press F7 to launch the viewer. The messages knap routine started and then ERR show up:

image

Could you elaborate on how to solve this issue? @andregpss please help me...

@frabjous
Copy link
Owner

frabjous commented Jun 2, 2024

That textopdfshorterror setting doesn't look like it does anything at all, which I would guess is why you're not getting any details about the error. What is the output if you run the pdflatex from a shell prompt?

I can't really provide help for Windows users, however.

@leanhdung1994
Copy link
Author

The command pdflatex.exe "C:\Users\Akira\Documents\LaTex\test.tex" runs perfectly fine in Windows PowerShell:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Users\Akira\Documents\LaTex> pdflatex.exe "C:\Users\Akira\Documents\LaTex\test.tex"
This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(c:/Users/Akira/Documents/LaTex/test.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-05-08>
(c:/texlive/2024/texmf-dist/tex/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(c:/texlive/2024/texmf-dist/tex/latex/base/size10.clo))
(c:/texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def)
No file test.aux.
[1{c:/texlive/2024/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./test.aux)
)<c:/texlive/2024/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on test.pdf (1 page, 16107 bytes).
Transcript written on test.log.
PS C:\Users\Akira\Documents\LaTex>

The resulted files are

image

@frabjous I totally understand that you do not use Windows, but thank you so much for reading my issue.

@andregpss
Copy link
Contributor

@leanhdung1994 Have you tried running the pdflatex command exactly as it is in the textpdf field in gknapsettings? Does your latex file compile with this command?
Another possibility: have you already installed the sioyek pdf reader? Was the executable for this reader included in the path? My configuration uses this reader.

@mathlab08
Copy link

mathlab08 commented Jun 3, 2024

@andregpss I followed the instructions to install it and after pressing F5,F6,F7,F8 respectively, nothing reflects. Can you show your init.lua, thanks!

@frabjous
Copy link
Owner

frabjous commented Jun 3, 2024

The shell command you showed isn't exactly what you have set in your settings. Try the exact command there at the shell (replacing %docroot% with the filename, run from the folder containing the file).

@leanhdung1994
Copy link
Author

leanhdung1994 commented Jun 3, 2024

@andregpss

  1. The command pdflatex -interaction=batchmode -halt-on-error -synctex=1 test.tex runs well in the terminal:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Users\Akira\Documents\LaTex> pdflatex -interaction=batchmode -halt-on-error -synctex=1 test.tex
This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
PS C:\Users\Akira\Documents\LaTex>

image

  1. I already installed sioyek v2.0.0 and added it to PATH

image

image

  1. I have recorded my process for your reference
Knap.mp4

@mathlab08
Copy link

mathlab08 commented Jun 3, 2024

In Windows, Neovim can't find Knap, you need to set system variables:
XDG_CONFIG_HOME=C:\Users\yourusername\.config
XDG_DATA_HOME=C:\Users\yourusername\AppData\Local
XDG_STATE_HOME=C:\Users\yourusername\AppData\Local
XDG_CACHE_HOME=C:\Users\yourusername\AppData\Local\temp
I made a portable setup (see attachment) and modified the paths to Neovim and TeXLive in StartNeovim.bat to run it.
https://www.mediafire.com/file/rv2zd1ungtzuf2b/PortableNeovim.zip/file

@leanhdung1994
Copy link
Author

@mathlab08 Could you explain where in Windows I should put such commands?

XDG_CONFIG_HOME=C:\Users\yourusername\.config
XDG_DATA_HOME=C:\Users\yourusername\AppData\Local
XDG_STATE_HOME=C:\Users\yourusername\AppData\Local
XDG_CACHE_HOME=C:\Users\yourusername\AppData\Local\temp

It seems you attachment has not been uploaded yet...

@andregpss
Copy link
Contributor

@mathlab08 I think it's not necessary to set these environment variables. I didn't need to do that. I installed knap through Plug.
@leanhdung1994 My neovim configuration can be found here. Pay attention to knap.vim and pluglist.vim.

I recorded the video below to show how the knap works. First I test sioyek, then pdflatex, and then run neovim. Next, I call the toggle_autopreviewing() command using the F7 key. Note that a message appears at the bottom of the video with the commands that knap runs. Ultimately, I call close_viewer() through F6.
(I used these shortcut keys to make it easier to understand as they are the default knap keys, but in my configuration, I changed these keys to F2 and Ctrl-F2, respectively).

knap_test.mp4

@mathlab08
Copy link

I'm using windows 7, without setting system variables, and neovim can't find Knap. also, there is an error with sioyek, and I can only preview with SumatraPDF renamed to sioyek.

sioyek

@frabjous
Copy link
Owner

frabjous commented Jun 5, 2024

The whole point of having configurable settings is so you can use whatever programs you want. You shouldn't have to rename something externally, and I'd definitely expect breakage if you did. Check if the windows version of Sioyek uses different command line arguments. If you don't know how command line arguments work to reconfigure it, I don't recommend that you use KNAP.

NeoVim not finding KNAP has nothing to do with KNAP. That's a problem with your Neovim package manager or whatever you used to install it.

@andregpss
Copy link
Contributor

@mathlab08 Can you use knap on Windows 7 by configuring these systems variables and using Sumatra?
What version of Sioyek did you install? Maybe it is an old version.
Microsoft has discontinued mainstream support for Windows 7; unsurprisingly, Knap and other plugins do not work.

@mathlab08
Copy link

mathlab08 commented Jun 5, 2024

Operating Environment:
Windows 7 Professionall
Neovim v0.9.0
sioyek v2.0.0
SumatraPDF v3.4.6
Git-2.45.1-64-bit

Install knap and pag.
$ mkdir -p ~/AppData/local/nvim-data/site/pack/plugins/start
$ cd ~/AppData/local/nvim-data/site/pack/plugins/start
$ git clone --depth 1 https://github.com/frabjous/knap.git
$ git clone --depth 1 https://github.com/savq/paq-nvim.git

Configured the system variables, and then follow your method of configuring init.lua, can be compiled correctly and synchronous preview PDF , but with sioyek v2.0.0 error.

@mathlab08
Copy link

mathlab08 commented Jun 10, 2024

@andregpss, as your configuration, in Windows, modify Knap.lua directly by changing the

    local dsettings = {
--   
        texoutputext = "pdf",
        textopdf = "pdflatex -interaction=batchmode -halt-on-error -synctex=1 %docroot%",
        textopdfviewerlaunch = "sioyek --inverse-search 'nvim --headless -es --cmd \"lua require('\"'\"'\"'knaphelper'\"'\"').relayjump('\"'\"'\"'\"'\"'% servername%'\"'\"','\"'\"'\"'%1'\"'\"', %2,%3)\"' --new-window %outputfile%",
        textopdfviewerrefresh = "none",
        textopdfforwardjump = "sioyek --inverse-search 'nvim --headless -es --cmd \"lua require('\"'\"'\"'knaphelper'\"'\"').relayjump('\"'\"'\"'% servername%'\"'\"','\"'\"'%1'\"'\"',%2,%3)\"' --reuse-window --forward-search-file %srcfile% --forward-search-line %line% %outputfile%",
        textopdfshorterror = "A=%outputfile% ; LOGFILE=\"${A%.pdf}.log\" ; rubber-info \"$LOGFILE\" 2>&1 | head -n 1"
--  
}

Modify to

    local dsettings = {
--   
        texoutputext = "pdf",
        textopdf = "pdflatex -interaction=batchmode -halt-on-error -synctex=1 %docroot%",
        textopdfviewerrefresh = "none",
        textopdfviewerlaunch = "sioyek --inverse-search \"nvim --headless -es\"  --new-window %outputfile%",
    --  textopdfviewerlaunch = "sioyek --inverse-search \"nvim --headless --cmd \"lua require('\"'\"'knaphelper'\"'\"').relayjump('\"'\"'%servername%'\"'\"','\"'\"'%1'\"'\"',%2,%3)\"\" --new-window %outputfile%",
        textopdfviewerrefresh = "none",
        textopdfforwardjump = "sioyek --inverse-search \"nvim --headless -es\" --reuse-window --forward-search-file %srcfile% --forward-search-line %line% %outputfile%",   
    --  textopdfforwardjump = "sioyek --inverse-search \"nvim --headless -c \"lua require('\"'\"'knaphelper'\"'\"').relayjump('\"'\"'%servername%'\"'\"','\"'\"'%1'\"'\"',%2,%3)\"\" --reuse-window --forward-search-file %srcfile% --forward-search-line %line% %outputfile%",   
        textopdfshorterror = "A=%outputfile% ; LOGFILE=\"${A%.pdf}.log\"" ,
--  
}

At this point, sioyek v2.0.0 can be previewed.

@andregpss
Copy link
Contributor

@mathlab08 Pretty cool! From what I understand, you changed fieldpdfviewerlaunch field by replacing the single quotes with \" and omitted the parameter that contains knaphelper. I don't really know if knaphelper is needed in this command. Anyway, I'm glad it worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants