[Tex/LaTex] beamer: Package hyperref Error: Wrong DVI mode driver option `ps2pdf’, (hyperref) because pdfTeX or LuaTeX is running in PDF mode

beamerhyperrefpdftexps2pdf

There are many questions with a similar title, but none of the answers seems to solve my problem. I get this error while preparing slides with beamer. It shows up only when using an up-to-date texlive distribution. When using packages from Ubuntu, it does not. By deleting lines, I saw that it looks like it is beamer that turns the error message on. The following code:

\documentclass{beamer}
%\usepackage[T1]{fontenc}
\mode<presentation>
{
  \usetheme{Madrid}
  \setbeamertemplate{navigation symbols}{}
}
%\usepackage[driverfallback=dvipdfm]{hyperref}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{frame}
  \titlepage
\end{frame}
\end{document}

provokes the message:

(/usr/local/texlive/2016/texmf-dist/doc/latex/listings-ext/hyperref.cfg

! Package hyperref Error: Wrong DVI mode driver option `ps2pdf',
(hyperref)                because pdfTeX or LuaTeX is running in PDF mode.

See the hyperref package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.24 }

? 

How can I get rid of that error? Using the driverfallback option as commented out or putting it as an option hyperref={driverfallback=dvipdfm} to class beamer does not help, nor does putting pdftex as an option to just about anything. I have absolutely no need to use listings-ext that contains hyperref.cfg file that sets that ugly ps2pdf option; it seems that beamer in the current texlive distribution loads it all by itself.

Best Answer

I have changed TEXINPUTS so that the initial part is no longer /usr/local/texlive/2016/texmf-dist// but it became /usr/local/texlive/2016/texmf-dist/tex//, and the example compiles, as well as the slides.