Closed jbkopecky closed 9 years ago
Hi. It seems you are experiencing two different problems. The first one is related to the viewer settings, while the second is related to the PID. The latter seems to be the important one. I think the first one may arise if you for instance have disabled the viewer module?
I don't personally use windows, and so windows debugging is difficult for me. I rely on other users to make this work. However, I will try to help: It seems to me that you are right that qprocess latexmk.exe
is the problem here. It should be easy to verify: In a cmd shell, first start latexmk for a tex project, then in a separate cmd shell test the output of qprocess latexmk.exe
. It should return the pid. If it does not, then this is indeed your problem.
If qprocess
does not work, and if you find another windows shell command that does work, similar to what you suggest, then please let me know. Also see #15.
I'll be rude enough to notify @petobens and @Konfekt, who was very helpful in implementing support for windows.
Yep, I have disabled the viewer module.
I was more worried about the PID issue as well. I am sorry I just saw the #15 issue.
I do not get any result from the cmd shell when running qprocess latexmk.exe
.
I do not know if this is because of my computer config or a Windows 8 issue.
I have had better results with Tasklist
, running: tasklist /v /fo csv | findstr /i "latexmk.exe"
that gives me an output that includes a latexmk PID (but haven't figured out how to properly parse it in vimcscript to isolate the PID).
I don't know if tasklist
is compatible with all windows versions though and it seems this command is a little slow...
Also, is the function systemlist() a vim builtin function ?
@lervag @jbkopecky Unfortunately I cannot provide any help since I don't use the latexmk functionality (because I use arara to compile my documents).
Hm. It's me who changed the command line to obtain the process ID to use qprocess
whereas before it was wmic process
and not working correctly for me under Windows 7 (as still existant in LaTeX BoX, see https://github.com/LaTeX-Box-Team/LaTeX-Box/blob/64eeb2dd9a0afd33ed8610a2d07416d126d5a2ef/ftplugin/latex-box/latexmk.vim#L333). One reason for qprocess
was that it is compatible with more Windows versions, starting from Windows XP Home.
@Konfekt Do you have any idea why qprocess
does not work for @jbkopecky on Windows 8.1?
It is difficult to find any information on qprocess
, but this seems to be related. @jbkopecky Does query process latexmk.exe
provide any output?
systemlist()
is an internal vim function, yes. You can read the docs with :h systemlist
. I think, though, that this function was introduced in a relatively recent version of vim, so it is interesting to know which version of vim you are using.
Btw: Could you please verify that my fix for the viewer
related error message works?
So here are the results:
query process latexmk.exe
is not recognized as a command. Do you think I am missing something in my path ?systemlist
: I do not have a help for this function on my windows vim (version 7.4 - Aug 10 2013) but I get it at home on my Linux more recent version. I am going to have to look for a more recent version I guess.First, could you check what happens when you in vim on windows do the following?
:echo systemlist('echo Hello World')
If systemlist
is not available, then this should give a similar error as before.
Regarding query process
, could the problem be that you do not have administrator access? Here it says "Administrators have full access to all query process functions", which could imply that query process is not available without administrator rights. See also here and here and here.
I'm sorry to say that I have no idea why this does not work for you. Perhaps the problem is mainly or only the lack of systemlist
?
Ok, so in fact I have two issues I guess:
:echo systemlist('echo Hello World')
leads me to an Unknown function error. I tried to reinstall vim from here but it was compiled in 2013 so I guess no systemlist
function yet.
qprocess latexmk.exe
and query process latexmk.exe
do work...The problem is that even when I fire up vim in admin mode, and run
:echo system('qprocess latexmk.exe')
it doesn't seem to run this command with admin rights...
Last Update: In fact, having systemlist
working made the error disappear as you said. I can now compile without seeing any issue. I guess Vimtex is only compatible with latest windows Gvim then.
However, I think that it did not fix the PID catch problem (due to admin rights limitations on Windows8) because everythime I toggle continuous compilation using <leader>ll
, it only starts it (and never stops it) and creates a new latexmk process every time.
Good to hear that things are starting to work.
Does your windows user generally have admin rights? If not, perhaps giving yourself admin rights will fix this problem?
@Konfekt @petobens Do you guys understand this thing? I'm really not very good with such kinds of windows issues...
For explanation: I switched from wmic process
to qprocess
because the former would not return a PID correctly on Windows 7, so that the second LatexMk instance would override the first. That is, with wmic
only a single LatexMk
instance would work.
Unfortunately there's little documentation about qprocess
. Perhaps it has been abandoned in Windows 8 together with the switch from cmd
to PowerShell
as default shell?
@jbkopecky has confirmed that qprocess
(an alias to query process
) is available, but only when it is run as administrator. The question is then how to ensure that the command is run as administrator.
However, this issue also raises the question if there should be a fallback method to get the PID. I.e. if qprocess
fails, then perhaps I should add a second method that does not need administrator rights?
Does wmic
work for you?
Does tasklist
have the same problem as that mentioned by @Konfekt?
I did a quick revert to try wmic
and it works for me (except that the cmd windows steals focus for a moment) I can start and stop compilation (i.e. it catches the appropriate PID)
About tasklist
, I am not sure to undesrtand the problem mentioned, so I can't really say. Are we trying to get several compilations cohexist without stealing each others latexmk processes ?
Yes. If wmic
works on Windows 8 but qprocess
not, than better revert to wmic
. However, under Win 7 the code as it used to be, would steal latexmk processes (as it did not read the PID correctly).
Ok, then I will add fallback code to use wmic
if qprocess
fails. I think this should work in most cases.
I just realized I have no way of testing. I think the following lines should work:
let pidcmd = 'wmic process where '
\ . '(CommandLine LIKE "latexmk\%' . a:data.tex . '\%") '
\ . 'get ProcessId /value | find "ProcessId"'
let a:data.pid = strpart(systemlist(pidcmd)[0], 10)
It would be very helpful if someone could test this. @jbkopecky
Also, @jbkopecky, it would be interesting to see if an alternative with tasklist
also works. Could you test and if needed modify the lines you suggested earlier, that is,
let pidcmd = 'tasklist /v /fo csv | findstr /i "latexmk.exe"'
let pid = split(systemlist(pidcmd)[-1], '\s\+')[-2]
so that the above code correctly gets the PID. This might lead to two possible fallbacks, which is better than one.
Also: It would be very helpful if you could let me know what the return value of systemlist(pidcmd)[-1]
is for the original qprocess
that does not work.
All right I'll have a look at it as soon as I get back on my Windows machine (monday)
Hello, sorry for the wait:
let pidcmd = 'wmic process where '
\ . '(CommandLine LIKE "latexmk\%' . a:data.tex . '\%") '
\ . 'get ProcessId /value | find "ProcessId"'
let a:data.pid = strpart(systemlist(pidcmd)[0], 10)
does not work for me. It gives me the following error (not very helpfull though):
The previous vimtex wmic command works for me though. I am not sure why this one fails.
let pidcmd = 'tasklist /fi "imagename eq latexmk.exe"'
let pid = split(systemlist(pidcmd)[-1], '\s\+')[1]
For example: In cmd console, the pidcmd returns:
1172
7820
in this case.I guess the lines are ordered by time of process creation so It works fine with me when I use tasklist command in vimtex. Could it be possible to test this pid command with different versions of windows ?
qprocess latexmk.exe
gives me: in cmd console.
Therefore, the resulting output for systemlist(pidcmd)[-1]
in vim is:
operable program or batch file.
Hope it helps !
Also, is it ok to replace
systemlist(pidcmd)
by:
split(system(pidcmd), '\n')
to avoid breaking compatibility with older vim versions ?
Please test if the latest commit fixes the compatibility issue and that it doesn't break anything.
The previous vimtex wmic command works for me though. I am not sure why this one fails.
Could you please be explicit on which wmic
command works for you? I don't think there was ever committed any wmic
commands to vimtex...
@Konfekt @jbkopecky Regarding qprocess: If I understand correctly from the earlier discussion, qprocess is only available when run as administrator. Could you please verify this? If this is the case, then qprocess is probably a bad choice for the default program to get the PID, since normal users should probably not generally have administrator rights?
@Konfekt I've pushed a change from qprocess to tasklist. Does the tasklist version work for you? Do you know a reason why not to use tasklist (if it works)?
For my part, tasklist
is just fine and I chose qprocess
only because it was the most prevalent among tasklist et al. (available from XP Home edition and above); to boot the previous wmprocess command was as cryptic as nonfunctional .
Since then I switched to OpenSuse, thus I cannot confirm that qprocess requires administrator rights because all online documentation was not clear on this. (Of Couse, when using vimtex on Windows 7, my user account had administrator rights.)
@Konfekt OK. Thanks for your input, anyway. If the latest version fixes the issue for @jbkopecky, and if it does not introduce any problems for other users, then I think this issue may be resolved.
It works for me ! Thanks !
Great!
Hello!
Thank you for this great plugin !
I am not sure about this one, but I get some errors when I start Latexmk compilation from my Gvim on Windows 8.
It looks like latexmk still can compile the .tex but I think it creates a new latexmk process instead of catching an existing one (when I stop and start continuous compiling several times, I end up with mutliple latexmk processes running)
I did have a look at the function that I think caused this error:
s:latexmk_set_pid()
at line 428 in latexmk.vim.Could the bug come from the line 431 ?:
I tried to run the command
qprocess latexmk.exe
from my windows command prompt (if I understand well, maybe it should have been something likesystem(pidcm)
instead ofsystemlist(pidcmd)
but I am afraid this doesnt get me any pid info output from any latxmk process.Then, should I try to run something like:
and then parse the answer to get latexmk process pid ?
I am not very good at vimscript or windows commands, but do you think this could be the issue I am having ?
Thank you for your help !
JB