diff --git a/sphinx/builders/__init__.py b/sphinx/builders/__init__.py index cfd005b1030..6e4464cd1d9 100644 --- a/sphinx/builders/__init__.py +++ b/sphinx/builders/__init__.py @@ -369,14 +369,14 @@ def build(self, docnames, summary=None, method='update'): else: logger.info(__('none found')) - # save the environment - from sphinx.application import ENV_PICKLE_FILENAME - logger.info(bold(__('pickling environment... ')), nonl=True) - with open(path.join(self.doctreedir, ENV_PICKLE_FILENAME), 'wb') as f: - pickle.dump(self.env, f, pickle.HIGHEST_PROTOCOL) - logger.info(__('done')) - if updated_docnames: + # save the environment + from sphinx.application import ENV_PICKLE_FILENAME + logger.info(bold(__('pickling environment... ')), nonl=True) + with open(path.join(self.doctreedir, ENV_PICKLE_FILENAME), 'wb') as f: + pickle.dump(self.env, f, pickle.HIGHEST_PROTOCOL) + logger.info(__('done')) + # global actions self.app.phase = BuildPhase.CONSISTENCY_CHECK logger.info(bold(__('checking consistency... ')), nonl=True)