LaTeXTools icon indicating copy to clipboard operation
LaTeXTools copied to clipboard

"No bib files found!" pop-up on `\cite{}`

Open kortschak opened this issue 8 years ago • 90 comments
trafficstars

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

kortschak avatar Apr 18 '17 23:04 kortschak

How do you add the bibliography? Does this also happen after you clear the cache (C-l, C-d, C-c)?

r-stein avatar Apr 19 '17 05:04 r-stein

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.

kortschak avatar Apr 20 '17 00:04 kortschak

Have you wrapped \bibliography{bibliography} inside an other command? Can you please provide a minimal working example, which produces the error?

r-stein avatar Apr 20 '17 08:04 r-stein

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.

kortschak avatar Apr 21 '17 01:04 kortschak

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.

r-stein avatar Apr 21 '17 05:04 r-stein

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.

kortschak avatar Apr 21 '17 06:04 kortschak

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.

r-stein avatar Apr 21 '17 07:04 r-stein

Similar problem. No .tex files can detect the bibliography one month after it was working fine.

lrdegeest avatar Apr 28 '17 02:04 lrdegeest

Exhibit A. Path to the .bib file is as it used to be. screen shot 2017-04-27 at 10 54 02 pm

lrdegeest avatar Apr 28 '17 02:04 lrdegeest

@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.

r-stein avatar Apr 28 '17 05:04 r-stein

Negative. MWE:

\begin{document}
Consider the lobster \citep{}
\bibliography{bibfile}
\end{document}

lrdegeest avatar Apr 28 '17 11:04 lrdegeest

@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.

r-stein avatar Apr 28 '17 11:04 r-stein

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.

lrdegeest avatar Apr 28 '17 12:04 lrdegeest

Can you press C-l, C-d, C-c and then check whether it still doesn't work?

r-stein avatar Apr 28 '17 12:04 r-stein

Already tried clearing the cache. No effect.

lrdegeest avatar Apr 28 '17 12:04 lrdegeest

Do you have any errors in the console ctrl+` ?

r-stein avatar Apr 28 '17 12:04 r-stein

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

lrdegeest avatar Apr 28 '17 12:04 lrdegeest

However, if I rename the file to "test.tex", changing nothing else, it works.

lrdegeest avatar Apr 28 '17 12:04 lrdegeest

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.

lrdegeest avatar Apr 28 '17 12:04 lrdegeest

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.

r-stein avatar Apr 28 '17 12:04 r-stein

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:

screen shot 2017-04-28 at 2 10 15 pm

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

screen shot 2017-04-28 at 2 10 42 pm

lrdegeest avatar Apr 28 '17 18:04 lrdegeest

Just to be clear, pdflatex and bibtex still compile a bibliography despite the message "No bib file found."

lrdegeest avatar Apr 28 '17 18:04 lrdegeest

@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.

ig0774 avatar Apr 28 '17 20:04 ig0774

Sorry, first line should be isn't instead of is.

ig0774 avatar Apr 28 '17 20:04 ig0774

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.

lrdegeest avatar Apr 28 '17 21:04 lrdegeest

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.

r-stein avatar Apr 29 '17 14:04 r-stein

Ok, thank you.

lrdegeest avatar Apr 29 '17 14:04 lrdegeest

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.

KTGLeiden avatar May 01 '17 09:05 KTGLeiden

I can confirm the same behavior on my machine. Renaming the document to test.tex fixed it.

superjax avatar May 01 '17 19:05 superjax

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)

brainbug89 avatar May 01 '17 21:05 brainbug89