SublimeText / LaTeXTools

LaTeX plugin for Sublime Text
https://latextools.readthedocs.io/
2.01k stars 365 forks source link

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

Open kortschak opened 7 years ago

kortschak commented 7 years ago

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
lrdegeest commented 6 years ago

Clearing the cache works, but why is it necessary to do so at the start of every project?

r-stein commented 6 years ago

I am not sure what the problem is and such problems are very hard to reproduce and hence to fix. I added that command to at least give the option to manually clear the cache if something went wrong and we need to rethink the cache structure, e.g. we could just keep the cache only in memory in some cases instead of additionally writing stuff to hard disk.

ig0774 commented 6 years ago

I think #1192 should fix this, at least the version of this I've been able to reproduce. But moving to a strictly in-memory cache would also fix things as well.

qiaojunfeng commented 6 years ago

Yes, clear cache works for me too!

kdzhang commented 6 years ago

Same problem, and clearing cache works for me!

gannebamm commented 6 years ago

I can confirm that the following multi-file and directory structure works nicely on my Windows machine:

- main.tex
- literature.bib
-\chapters\
            | intro.tex
            | methods.tex
            | ....tex

If I start every chapters/....tex file with % !TEX root = ..\main.tex Is there any documentation for LaTeXTools for handling multi-file projects? I have never seen this command before.

r-stein commented 6 years ago

You can find the documentation here https://latextools.readthedocs.io/en/latest/features/#multi-file-documents

You should use a normal slash in the path to the root file to be compatible with other OS and editors, I.e. %!TEX root = ../main.tex

Aside: you may also be interested that you can auto insert that command on file creation from the \inputcommand see

kristtja commented 6 years ago

This problem occurred to me today as well, but only after converting my citations from bibtex to biblatex. I've tried everything you guys have posted and nothing worked. The only way I managed to solve this was to revert everything back to bibtex... Are there any other things one might try to solve this problem?

ig0774 commented 6 years ago

When you converted the file, how did you load the bibliography?

ig0774 commented 6 years ago

E.g. \addbibresource must have the file name with the .bib extension, unlike with straight BibTeX.

kristtja commented 6 years ago

The bibliography is loaded in a custom .sty file with

\RequirePackage[backend = biber, style = authoryear, maxnames = 2]{biblatex} \addbibresource{bibliography.bib} \renewcommand*{\nameyeardelim}{\addcomma\space}

and then added added in the main.tex file using \printbibliography.

For bibtex the entry in the .sty file is \RequirePackage{natbib} and then the main.tex file has \bibliographystyle{myBibStyle.bst} \bibliography{bibliography}

What was really weird is that ST2 managed to find the .bib file the first 5-10 minutes after converting, and then the error suddenly appeared. The same happened when I tried to create new files in a different folder. I have also tried to change to ST3 but the error still happened.

My main.tex, .bib file, and .sty file are all in the same folder. The different sections lies in a subfolder. All documents in the subfolder has the line %!TEX root = ../main.tex as their first line.

ig0774 commented 6 years ago

This has a fairly easy answer then: LaTeXTools doesn't currently support finding bibliographies defined in custom style files. Only those defined in the main document or files \inputed or \imported will be found.

To get this to work, you'd need to add something like the following to your document preamble:

\newcommand{\nop}[1]{}
\nop{\addbibresource{bibliography.bib}}
kristtja commented 6 years ago

Added the commands to the preamble, but unfortunately nothing changed. I also tried to add the bibliography in the preamble using

\usepackage[backend = biber, style = authoryear, maxnames = 2]{biblatex}
\bibliography{bibliography.bib}
\renewcommand*{\nameyeardelim}{\addcomma\space}

but that didn't help either.

ig0774 commented 6 years ago

Sorry, I forgot to add that you need to run the LaTeXTools: Clear Cache command after making the changes.

kristtja commented 6 years ago

Tried to clear the cache, but the error still occurs. Any other ideas?

lrdegeest commented 6 years ago

You may need to clear multiple caches

screen shot 2018-02-07 at 9 00 11 am

kristtja commented 6 years ago

Still not working :( I might just have to convert to biblatex when I'm done with my thesis.

cipri-tom commented 6 years ago

TL;DR: check you correctly specify the TEX ROOT (main.tex) path in your sub-files !

I ran into this error today and clearing the cache didn't solve it. But then I checked the console ctrl+` and I saw my main.tex wasn't found. Specifically, it was searching for ..../thesis/Chapters/main.tex whereas my main.tex was in the root ..../thesis. Easy to spot, therefore: At the beginning of the chapter file I had %!TEX root = main.tex, whereas I should've had %!TEX root = ../main.tex

Markdown is hard: ctrl+` == ``ctrl+` ``

justinesarey commented 6 years ago

Getting "no bib file found" error. Clearing all caches does not appear to remedy the error. Console returns:

TEX root: 'C:\Dropbox\jesarey_documents\Gender Corruption Instrument\2018-3-5_gender-corruption-and-causality-presentation.tex' Bib files found: [] error: No bib files found!

...so TEX root is correctly identified (that is, in fact, the location of the master .tex file). Weirdly, this was working for a while and then suddenly stopped working. Now I can't get it working again.

kristtja commented 6 years ago

@cipri-tom: I have the same setup as you, and the have always had %!TEX root = ../main.tex as the path. The bibliography compiles just fine when using biblatex. The problem is that I can't use biblatex as I'm writing because sublime refuse to acknowledge that there is a bib-file loaded in the custom .sty-file (nor when it's added directly in the main.tex file for that matter). This means that whenever I try to enter a citing using biblatex I get the error "No bib file found".

I also had (kind of) the same experience as @justinesarey as citing with biblatex was working fine until it suddenly stopped working some 10 minutes after I did the switch from bibtex to biblatex.

qm1900 commented 6 years ago

I have two projects which share the same bib file via absolute path, and of course the \bibliography{} in both files are the same.

however, one can pop up the bib list successfully, another cannot

''latextools: clean caches'' works for me

Whadup commented 5 years ago

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.

I've had the same behavior, main.tex seems to work reliably, anything else might fail.

pabloarcadio commented 5 years ago

The same message "No bib files found" when writing \cite{} in the chapter.tex. I understand after reading the comments that this is due to the use of .tex as chapters (inside the main.tex comand \cite{} works perfectly). Then I did what user @cipri-tom commented about placing this line in every chapter: %!TEX root = ../main.tex but still is not working at goes on the message of "Non bib file found". Any ideas?

r-stein commented 5 years ago

@pabloarcadio what is the folder structure of your project? Are the chapters in a subfolder of the master document?

project/
├── chapters/
│   ├── chapter.tex
│   └── other-chapter.tex
└── main.tex
pabloarcadio commented 5 years ago

Yes @r-stein , it is almost like that: there are folders inside chapters/ project/ _chapters/ ____chapter01/ ___chapter01.tex ___main,tex

r-stein commented 5 years ago

In that folder structure you need to change it to

%!TEX root = ../../main.tex

I.e. the relative path to the main file.

pabloarcadio commented 5 years ago

Sorry, buy I don't understand what you mean. I wrote at the beggining (just before the \begin{document} of the main.tex this: %!TEX root = D:/Doctorado/Tesis/Tesis Latex/memoirthesis.tex and inside the chapter01.tex the same: %!TEX root = D:/Doctorado/Tesis/Tesis Latex/memoirthesis.tex % \let\textcircled=\pgftextcircled \chapter{Prólogo} \label{chap:intro}

It is that approach correct? Thanks

r-stein commented 5 years ago

I am not sure whether your main.tex file differs from memoirthesis.tex, The tex root should be the file you always compile and it is in fact used when you compile via C-b. You can check the tex root view opening the ST console C-` and then writing:

from LaTeXTools.latextools_utils import tex_directives
tex_directives.get_tex_root(view)

I don't know of there are problems with absolute paths or spaces in the path, but that setting looks correct to me. Note that you don't need to set the main file inside your main file.

pabloarcadio commented 5 years ago

Thanks @r-stein. I have solved the problem and now I can see the bibliography list in every chapter. The solution is to place as the root not only the main file: %!TEX root = ../../main.tex but as well the biblio file: %!TEX root = ../../biblio.tex

Don't ask me why but it works!

r-stein commented 5 years ago

@pabloarcadio If you use the same tex directive twice one will win, it will just use biblio.tex as the tex root, which is okay for the \cite command, but will interfere with other features (quick build, command completions, ...). If that's okay for you can do it like this.

mariobiondi1 commented 5 years ago

Solution for Sublime Text 3

It generally appears when working in a structure where main file is kept in one folder while child documents are kept in a subfolder

    -  directory
  -   main.tex
  -   (subdirectory)chapters
  -   (subdirectory)images

Individual chapters files are kept in chapters subdirectory.

Solution

  • Do not make individual chapter files rather write all chapter codes in main.tex
  • Rename the file 'main.tex' to 'test.tex' (removes error for no bib file found)
  • Change bibliography style to apalike. later on change to whatever you wish to after deleting the auxiliary files. (removes error for citation undefined)

The above three changes can guarantee the solution with 90% probability.

I wanted to keep making individual chapter files to keep the main.tex file clean. The issue remained tho; while trying the \cite{} command inside an individual chapter file, the "no bib files found" pop-up showed up.

What solved it for me, beside naming main.tex into test.tex, was separating the whole preamble into a header.tex file which is then included in the test.tex file via the \input{} command. The \addbibresource{} is inside the header.tex file.

lrdegeest commented 4 years ago

Somehow this is still a problem. Just today I fired up a brand new document and got the dreaded "No bib files found!"

Here is an example:

\documentclass{article}
\usepackage{natbib}
\begin{document}
Consider the lobster \citep{acheson1988lobster}
\bibliographystyle{chicago}
\bibliography{references}
\end{document}

As usual, clearing the caches does nothing.

Will this bug ever be fixed?

ig0774 commented 4 years ago

@lrdegeest So, just to be clear, the issue here isn't one bug, but a series of different configurations or setups that sometimes don't play well with LaTeXTools. The problem is generating a reproducible example of an issue so we can fix it.

For example, on the latest pre-release, with a file named references.bib in the same directory as my saved tex document with the contents you gave, I don't get the "No bib files found!" message. Could you please post the contents of your ST console when that error occurs? We might be better able to track down what is happening from there.

kristtja commented 4 years ago

Hi again, I'm trying to give biblatex another chance, but yet again I'm getting the "No bib files found" error. What's extra interesting is that I'm now on a Windows machine and not a Mac.

The \addbibresource is in the preamble of the main-file, the subsections all have %!TEX root = ../main.tex in the top, and of course the bib-file is in the same folder as the main-file. I've also tried to clear the cache multple times.

I've tried ignoring the error and writing down the reference key and get the error that the citation is undefined.

When the "No bib files found" error shows uo, the console says: TEX root: 'C:\Users\cvkt5\OneDrive - Loughborough University\PhDThesis\main.tex' Bib files found: () error: No bib files found!

So at least it's pointing to the correct path to the main-file

samuelbl commented 4 years ago

add "%! TEX root = ../main.tex" on all files that are not in the home directory worked for me

KSokol79 commented 3 years ago

@samuelbl

add "%! TEX root = ../main.tex" on all files that are not in the home directory worked for me

Does this approach allow you to compile the subfiles? I am under the impression putting %! TEX root at the top of the subfile overrides the setting. Has the workaround been developed?

thistlillo commented 2 years ago

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

I had the same issue (no bib file found, but it was well present) and this solved the issue in my case.

ultravioletcatastrophe commented 1 year ago

This seems to still be an issue, and the only thing that seems to work is manually generating a .bbl file via bibtex __

connbrack commented 1 year ago

Just solved my issue, likely not a universal fix, but in case it helps someone:

I import my packages from an .sty file, where I had my \addbibresource{bibliography.bib}

When i moved my \addbibresource{bibliography.bib} to my main .tex file my issue was solved. BUT only after i closed and reopened sublime (I would have figured this out much earlier, but when I tried this before i didn't restart sublime).

I also removed all my build files before restarting. Not sure if this was required.

githubedu commented 1 year ago

When i moved my \addbibresource{bibliography.bib} to my main .tex file my issue was solved. BUT only after i closed and reopened sublime (I would have figured this out much earlier, but when I tried this before i didn't restart sublime).

Yes, after trying many recommendations that has been mentioned before. Closing and opening sublime solve the problem. My advice is: Try something, then close and open sublime.