BibTeX Reference Completion Crashes with "Can't open file tmpfile.bbl" #762

Closed
opened this Issue Apr 6, 2017 · 8 comments

Projects
None yet
4 participants

gkapfham commented Apr 6, 2017 • edited

 Hello @lervag! Thanks for developing this plugin. As you know, I use it on a regular basis. I updated my version of vimtex today and found that I could no longer complete references without an error. Here are the relevant settings from my vimrc file: autocmd FileType tex set omnifunc=vimtex#complete#omnifunc " Configure vimtex let g:vimtex_latexmk_options="-pdf -pdflatex='pdflatex -file-line-error -shell-escape -interaction=nonstopmode -synctex=1'" let g:vimtex_fold_enabled = 0 let g:vimtex_quickfix_mode = 2 let g:vimtex_quickfix_open_on_warning = 0 let g:vimtex_toc_resize = 0 let g:vimtex_toc_hide_help = 1 let g:vimtex_indent_enabled = 1 let g:vimtex_latexmk_enabled = 1 let g:vimtex_latexmk_continuous = 1 let g:vimtex_latexmk_callback = 1 let g:vimtex_complete_recursive_bib = 0 let g:vimtex_view_method = 'mupdf' let g:vimtex_view_mupdf_options = '-r 288' if !exists('g:ycm_semantic_triggers') let g:ycm_semantic_triggers = {} endif let g:ycm_semantic_triggers.tex = [ \ 're!\$A-Za-z]*cite[A-Za-z]*(\[[^]]*$){0,2}{[^}]*', \ 're!\$A-Za-z]*ref({[^}]*|range{([^,{}]*(}{)?))', \ 're!\\hyperref\[[^]]*', \ 're!\\includegraphics\*?(\[[^]]*$){0,2}{[^}]*', \ 're!\\(include(only)?|input){[^}]*', \ 're!\\\a*(gls|Gls|GLS)(pl)?\a*(\s*$[^]]*$){0,2}\s*\{[^}]*', \ 're!\\includepdf(\s*$[^]]*$)?\s*\{[^}]*', \ 're!\\includestandalone(\s*$[^]]*$)?\s*\{[^}]*', \ 're!\\usepackage(\s*$[^]]*$)?\s*\{[^}]*', \ 're!\\documentclass(\s*$[^]]*$)?\s*\{[^}]*', \ ]  Please note that I have not yet reproduced this defect with a minimal vimrc file. But, I am glad to do so if you ask me to complete this task. However, I can reliably reproduce the problem on an Ubuntu 16.04 workstation running the following version of LaTeX: pdfTeX 3.14159265-2.6-1.40.17 (TeX Live 2016) kpathsea version 6.2.2 Copyright 2016 Han The Thanh (pdfTeX) et al. There is NO warranty. Redistribution of this software is covered by the terms of both the pdfTeX copyright and the Lesser GNU General Public License. For more information about these matters, see the file named COPYING and the pdfTeX source. Primary author of pdfTeX: Han The Thanh (pdfTeX) et al. Compiled with libpng 1.6.21; using libpng 1.6.21 Compiled with zlib 1.2.8; using zlib 1.2.8 Compiled with xpdf version 3.04  I am currently using the following version of vim: VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Dec 23 2016 18:16:55) Included patches: 1-134  I have the following content in my latexmkrc file: $print_type = 'pdf';$pdf_mode = 1; $bibtex_use = 2; push @generated_exts, "cb"; push @generated_exts, "cb2"; push @generated_exts, "spl"; push @generated_exts, "nav"; push @generated_exts, "snm"; push @generated_exts, "tdo"; push @generated_exts, "nmo"; push @generated_exts, "brf"; push @generated_exts, "nlg"; push @generated_exts, "nlo"; push @generated_exts, "nls"; push @generated_exts, "synctex.gz"; push @generated_exts, "tex.latexmain"; push @generated_exts, "run.xml";$latex = 'latex --src-specials %O %S'; $pdflatex = 'pdflatex -file-line-error -synctex=1 -interaction=nonstopmode -shell-escape %O %S'; # If zero, check for a previously running previewer on the same file and update it. If nonzero, always start a new previewer.$new_viewer_always = 0; # How to make the PDF viewer update its display when the PDF file changes. See the man page for a description of each method. $pdf_update_method = 2; # When PDF update method 2 is used, the number of the Unix signal to send$pdf_update_signal = 'SIGHUP'; add_cus_dep('nlo', 'nls', 0, 'nlo2nls'); sub nlo2nls { system("makeindex $_[0].nlo -s nomencl.ist -o$_[0].nls -t \$_[0].nlg" ); }  At the outset, I acknowledge that all of these settings may no longer be needed in order to correctly run vimtex. Also, I suspect that these issues are not related to the error that I am experiencing. But, with that said, I always see the error when I try to complete references with this minimal.tex: \documentclass[11pt]{article} \usepackage{cite} \begin{document} This is a great paper~\cite{Codd1970}. \bibliography{minimal} \bibliographystyle{plain} \end{document}  I would also have the following minimal.bib file: @Article{Codd1970, author = {Codd, E. F.}, title = {A relational model of data for large shared data banks}, journal = {Communications of the ACM}, year = {1970}, volume = {13}, issue = {6}, optpages = {377--387} }  Finally, the error always manifests itself in roughly the following fashion. First, I will start typing ~\cite{ and the completion menu from YouCompleteMe will not correctly appear. At this point, I will always see the following error message: Omnifunc returned bad value to YCM! Vim(let):E484: Can't open file tmpfile.bbl  If I look in the file system, I will indeed notice that the tmpfile.bbl file is not in the directory. However, when I attempt to type ~\cite{ the second time the completion will work correctly and I can select Codd1970 from the YouCompleteMe menu. This alternating behavior will continue: it will not work, then work, and then not work, again and again and again. Of course, I am very far from an expert when it comes to understanding the codebase of vimtex. However, it seems like the source code may have a race condition in it. That is, the tmpfile.bbl file seems to be appearing very shortly after vimtex looks for it so that it can prepare the values that will be displayed by YouCompleteMe. Again, I recognize that my intuition about this may be incorrect. So, you are welcome to ignore this point if it is not helpful! Is it possible that the recent changes to the plugin are connected to this issue? Is there any other information that you need from me to support your reproduction of the problem? Overall, it would be awesome if you can investigate this matter and, if it is a problem, suggest a workaround for me or implement a fix in the main system. Thanks again for this plugin and for taking the time to investigate this matter!
Contributor

andymass commented Apr 6, 2017 • edited

 Can confirm. This change seems to be the most immediate cause. Also, is there a reason tempname() isn't used, but vimtex always uses tmpfile.bbl?
Owner

lervag commented Apr 6, 2017

 First a comment on your vimtex settings. There have been some pretty large updates the last couple of weeks. Your vimtex settings should be equivalent to these updated settings: let g:vimtex_fold_enabled = 0 let g:vimtex_quickfix_open_on_warning = 0 let g:vimtex_index_show_help = 0 let g:vimtex_view_method = 'mupdf' let g:vimtex_view_mupdf_options = '-r 288' Also, you should not need to use an autocmd to set the omnicompletion, since vimtex already does this for you. Now, to the issue: I've made some pretty large updates to how vimtex runs external processes, and this issue is related to that. I remembered to test the completion earlier, but not for the most recent updates. Your minimal working example is reproducible, and I think I will have this fixed pretty soon. @andymass There is not particular reason. However, it should not matter, since tmfile.bbl is deleted after use anyway. Or am I missing something?

lervag added a commit that referenced this issue Apr 6, 2017

 Added test files for #762 
 746cffc 

Owner

lervag commented Apr 6, 2017

 Ok, it should be fixed now.
Owner

lervag commented Apr 6, 2017

 Sorry for the inconvenience. A lot of the recent changes have been refactoring and API changes in order to make it easier/possible to implement some new features, e.g. other compiler backends (e.g. latexrun, see #651), other backends for error parsing, and supporting the new jobs API in Vim/neovim.

Rmano commented Apr 6, 2017

 Yes! Nice changes, and it's normal to have some bump along the road. Worthwhile, I think, and fundamental in any SW project so that it doesn't rot. Thank you very much for taking the time of doing all this.
Owner

lervag commented Apr 6, 2017

 It's my pleasure. Although it's been a lot of work, it's both fun and interesting work! :)

gkapfham commented Apr 10, 2017

 Hello @lervag! Thanks for fixing this issue. I am writing to confirm that it is resolved. I have edited several multiple-file papers in LaTeX in the past few days and I have not had any problems in completing the references. Again, thanks for your commitment to the development of vimtex!
Owner

lervag commented Apr 10, 2017

 Great, thanks for letting me know! Den man. 10. apr. 2017, 03.58 skrev Gregory M. Kapfhammer < notifications@github.com>: … Hello @lervag ! Thanks for fixing this issue. I am writing to confirm that it is resolved. I have edited several multiple-file papers in LaTeX in the past few days and I have not had any problems in completing the references. Again, thanks for your commitment to the development of vimtex! — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#762 (comment)>, or mute the thread .