LaTeXTools
LaTeXTools copied to clipboard
"No bib files found!" pop-up on `\cite{}`
Recently (past week or so) LaTeXTools has been popping up the "No bib files found!" error dialog.
Installed version of LaTexTools is v3.13.5. SublimeText 3 Build 3126.
Console:
TEX root: '/path/to/document.tex'
Bib files found:
[]
error: No bib files found!
Shell:
$ ls /path/to | head -n 1
bibliography.bib
How do you add the bibliography? Does this also happen after you clear the cache (C-l, C-d, C-c)?
How do you add the bibliography?
The bibliography is included with \bibliography{bibliography} and the bibliography.bib file is placed in the working directory. This worked until recently (it would be surprising to me for that to not work).
Does this also happen after you clear the cache (C-l, C-d, C-c)?
No change.
Have you wrapped \bibliography{bibliography} inside an other command? Can you please provide a minimal working example, which produces the error?
My minimal reproducer is
\begin{document}
\cite{}
\verb|\end{document}|
\bibliography{bibliography}
\end{document}
with a valid bibliography.bib.
Removing the \verb|\end{document}| fixes the problem, so I suspect that the quoted \end{document} is being parsed as \end{document} rather than text.
Yes you are correct the analysis stops at \end{document} and is not smart enough to detect such cases.
You can try to remove that line. Not sure what would be the best to solve this in general.
That text is only there in placeholder text in my case, so this is not a huge issue. For others, a work around is to replace that with \verb|\|\verb|end{document}|. Ugly, but workable.
Removing that whole condition also fixes the problem. It would seem that erroring in greediness would be better that in the other direction.
Removing that whole condition also fixes the problem. It would seem that erroring in greediness would be better that in the other direction.
I tend to agree on that.
Similar problem. No .tex files can detect the bibliography one month after it was working fine.
Exhibit A. Path to the .bib file is as it used to be.

@lrdegeest Do you also have \end{document} inside a verb inside your document? Otherwise it would also be good, if you good provide a minimal working example.
Negative. MWE:
\begin{document}
Consider the lobster \citep{}
\bibliography{bibfile}
\end{document}
@lrdegeest Then it is an other bug and it would be nice if you could create a new issue as I can't reproduce it.
Sure, but one last point. The problem is also sensitive to the name of a file. "test.tex" works; "experiment.tex" or "asasdfl.tex" (random letters) do not.
Can you press C-l, C-d, C-c and then check whether it still doesn't work?
Already tried clearing the cache. No effect.
Do you have any errors in the console ctrl+` ?
Yes:
Running "'' -version"
Traceback (most recent call last):
File "/Users/LawrenceDeGeest/Library/Application Support/Sublime Text 3/Packages/LaTeXTools/st_preview/preview_utils.py", line 99, in _update_gs_version
raw_version = check_output([_GS_COMMAND, '-version'])
File "/Users/LawrenceDeGeest/Library/Application Support/Sublime Text 3/Packages/LaTeXTools/latextools_utils/external_command.py", line 348, in check_output
show_window=show_window
File "/Users/LawrenceDeGeest/Library/Application Support/Sublime Text 3/Packages/LaTeXTools/latextools_utils/external_command.py", line 268, in execute_command
show_window=show_window
File "/Users/LawrenceDeGeest/Library/Application Support/Sublime Text 3/Packages/LaTeXTools/latextools_utils/external_command.py", line 221, in external_command
cwd=cwd
File "./python3.3/subprocess.py", line 819, in __init__
File "./python3.3/subprocess.py", line 1370, in _execute_child
File "./python3.3/os.py", line 791, in fsencode
TypeError: expect bytes or str, not NoneType
However, if I rename the file to "test.tex", changing nothing else, it works.
In fact, I am noticing that the problem arises in any tex file if if move it. This should not be a problem because I provide the absolute path to the bibliography, and anyway, it worked perfectly fine before.
That error is not related to that (and not really problematic).
We have changed things in that completion, because we now use a backward analysis to extract information of the document instead rewritting that feature everywhere (this adds support for the import package). It doesn't seem to support absolute paths.
Can you try to change this line to:
if not os.path.isabs(res):
candidate_file = os.path.normpath(os.path.join(rootdir, res))
else:
candidate_file = os.path.normpath(res)
You can use PackageResourceViewer to edit the files.
On the contrary, it is quite problematic!
Changing the line in the python file has no effect. For example, I create an empty file called "results.tex" and add a path to the bibliography. Nada:

but if I change the file name to "test.tex" (mv results.tex test.tex), suddenly it works:

Just to be clear, pdflatex and bibtex still compile a bibliography despite the message "No bib file found."
@r-stein wasn't saying the "No bib files" message is problematic. It's the output from the console you showed that indicates a problem finding Ghostscript on your machine, which is completely unrelated to the bibliography problem.
Unfortunately, it's not possible to reproduce the error you're showing from the MWE you provided on my machine, which just indicates that the problem isn't obvious just from the example you provided. Can you be a bit more detailed as to the steps you're taking to produce this issue? You seem to be renaming the file via mv; is this change immediately reflected in ST or do you somehow reopen the file once it's been renamed? Being specific and clear will help us to help you.
Sorry, first line should be isn't instead of is.
Thanks a lot for your help. I recreated the problem with a fresh example. I created a directory called "mypaper":
└── mypaper
├── conclusion.tex
├── intro.tex
├── main.tex
└── results.tex
where the child documents are added to "main.tex" via \input{}.
"main.tex" looks like this:
\begin{document}
Consider the lobster \citep{acheson1988lobster}
\section{Introduction}
\input{intro}
\section{Results}
\input{results}
\section{Conclusion}
\input{conclusion}
\bibliographystyle{chicago}
\bibliography{/Users/LawrenceDeGeest/Desktop/notebook/references}
\end{document}
and "intro.tex" looks like this:
%\bibliography{/Users/LawrenceDeGeest/Desktop/notebook/references}
Consider the lobster \citep{}
I add the commented-out references file at the top so I can use the wonderful auto-fill feature when typing \citep{}. However, this now produces the "no bib file found" message. Strange because it used to work just fine.
Stranger yet is that copy-pasting a working file to a new, empty file in a new, empty directory causes it to break. Suppose I create a new directory called "mypaper2" and add a blank "main.tex" file, then copy the contents from mypaper/main.tex to mypaper2/main.tex. This should be fine, but instead it leads to an error.
Some more detail. I have this tree:
├── mypaper
│ └── main.tex
└── mypaper2
└── main.tex
Here is the output from ctr+' on mypaper/main.tex:
TEX root: '/Users/LawrenceDeGeest/Desktop/notebook/latex_sandbox/sublime/mypaper/main.tex'
Bib files found:
('/Users/LawrenceDeGeest/Desktop/notebook/references.bib',)
and here is the output on mypaper2/main.tex:
Exception KeyError: KeyError('/Users/LawrenceDeGeest/Desktop/notebook/latex_sandbox/sublime/mypaper2/main.tex',) in <bound method LocalCache.__del__ of <LaTeXTools.latextools_utils.cache.LocalCache object at 0x10c33d050>> ignored
Exception KeyError: KeyError('/Users/LawrenceDeGeest/Desktop/notebook/latex_sandbox/sublime/mypaper2/main.tex',) in <bound method LocalCache.__del__ of <LaTeXTools.latextools_utils.cache.LocalCache object at 0x10c33dad0>> ignored
TEX root: '/Users/LawrenceDeGeest/Desktop/notebook/latex_sandbox/sublime/mypaper2/main.tex'
Bib files found:
()
error: No bib files found!
Exception KeyError: KeyError('/Users/LawrenceDeGeest/Desktop/notebook/latex_sandbox/sublime/mypaper2/main.tex',) in <bound method LocalCache.__del__ of <LaTeXTools.latextools_utils.cache.LocalCache object at 0x10c2dc1d0>> ignored
All these files compile accordingly with references included, whether I build from Sublime or from the command line.
and "intro.tex" looks like this:
%\bibliography{/Users/LawrenceDeGeest/Desktop/notebook/references} Consider the lobster \citep{}
Writing \bibliography inside comments is not supported anymore.
The recommended way is to write % !TEX root = main.tex at the top of each included document. We may also provide a way to add some meta information in the comments.
The other seems to be a bug, if the same bibliography is used by two documents. We will have a look at this.
Ok, thank you.
Just to let you know, I have the same issues with the latest Git version. Renaming the document to test.tex works great. Thanks for the fix and for looking into this.
I can confirm the same behavior on my machine. Renaming the document to test.tex fixed it.
I have the same problem. I getting the "No bib files found!" pop-up when trying to use \cite{}
Here is the output from the console on zusammenfassung.tex:
TEX root: 'D:\\privat\\xxx\\xxx\\xxx\\xxx\\xxx\\xxx\\version06\\contents\\zusammenfassung.tex'
Bib files found:
[]
error: No bib files found!
The TEX root is wrong. Looks like the "TEXroot": "main.tex", setting at the .sublime-project suddenly doesn't work anymore. (btw \cite{} works fine at main.tex)