[Tex/LaTex] Latexmk says the file is up-to-date, while it’s not

latexmkpdftex

For some reason the pdflatexmk typesetter is sometimes not recognising changes in my file and it returns:

Latexmk: All targets (main.pdf) are up-to-date

while the target is not up-to-date.
When I type something in three.tex, click save and then typeset, sometimes it typesets fine, sometimes it shows the above message.
When the above message is shown I need to type some more text, and try to typeset again. After several tries it will typeset normally.

I've included a stripped down version of my files below:

main.tex:

% !TEX TS-program = pdflatexmk

\documentclass[12pt,a4paper,titlepage,final]{report}

\usepackage[paper=a4paper, hmargin=2.5cm, vmargin=0cm]{geometry} 
\usepackage{caption}                    
\usepackage{geometry}
\usepackage{fancyhdr}                   
\usepackage{graphicx}                   
\usepackage[toc,nonumberlist]{glossaries}       
\usepackage{pdfsync}                    
\usepackage[T1]{fontenc}                    
\usepackage[applemac]{inputenc}         
\usepackage[section]{placeins}                    
\usepackage{parskip}                    
\usepackage{amsmath}                    
\usepackage{natbib}                 
\usepackage{tikz}                       
\usepackage{pgfplots}                   
\usetikzlibrary{plotmarks}          

\includeonly{chapters/three}

\begin{document}
\include{chapters/one}
\include{chapters/two}
\include{chapters/three}

\bibliographystyle{apalike}
\biblipgraphy{refs}
\addcontentsline{toc}{chapter}{Bibliography}

\end{document}

three.tex (located in folder ./chapters):

% !TEX root = ../main.tex
\chapter{Three}
\label{chap:three}

Text, figures and equations

I'm using TeXShop 3.23 on Mac OSX 10.8.4. It all worked fine for months with this setup, but now something has changed (no clue what).

Update:
I found a file in the main directory named pdflatex24719.fls that contained the following:

PWD /Users/user/Documents/Dropbox/main
INPUT /usr/local/texlive/2012/texmf.cnf
INPUT /usr/local/texlive/2012/texmf/web2c/texmf.cnf

I've never seen the file before, so I decided to delete it. After deletion all worked fine again as it should.

Update 2:
And the behaviour is back again. Although I have changed the text in three.tex pdflatexmk still says it's up-to-date.

Update 3:
I found out that the .pdf is updated. When I open it with Preview.app I see the updated version. However, the TexShop preview window keeps showing the old .pdf file.

Update 4:
Following the advice of texenthusiast I created a sample bibliography refs.bib and a sample tex file sample.tex. The latter looks as follows:

\documentclass[12pt,a4paper,titlepage,final]{report}
\begin{document}

test citing~\cite{Rom1992}

\bibliographystyle{apalike}
\bibliography{refs}
\end{document}

While in the folder of the sample.tex I ran latexmk -pdf sample.tex in the Terminal and checked the pdf file. After I made an edit to the .tex file I ran the command again. The change was reflected in the pdf file.

Best Answer

This happens to me frequently. When it does, the cause is always the same. I compile to pdf, but while I have the existing pdf from the last compile open in Acrobat Reader. The compile completes but cannot write to the pdf. If I then recompile I get your error (i.e pdf is not up to date, but the compiler says it is).

The solution is to delete the pdf before re-compiling the second time.