Skip to content

Commit

Permalink
Do not attempt to create additional template paths. (#1646)
Browse files Browse the repository at this point in the history
* Do not attempt to create additional template paths.

Fixes #1430

Many users are reporting that nbconvert 6.x has permission errors when queried or converting files. These seem to arise when nbconvert is installed as root, then used as a user. We hypothesize that the code removed in this commit, which attempts to create template directories throughout the jupyter path hierarchy, succeeds in creating template directories when running as root. Note that it creates the template directories with permission 700. Those permissions as root mean that regular users won’t be able to read these directories, and those are the sort of permission errors we are seeing reported.

This directory creation was originally introduced in #1028, where I think it was limited to a single user configuration directory (based on the PR discussion). In #1056, this code appears to have been copied over and applied to the entire Jupyter directory hierarchy.

* Filter additional template paths to existing paths to be consistent.
  • Loading branch information
jasongrout authored Sep 17, 2021
1 parent da5bb65 commit 3e57a03
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions nbconvert/exporters/templateexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from traitlets.config import Config
from traitlets.utils.importstring import import_item
from jupyter_core.paths import jupyter_path
from jupyter_core.utils import ensure_dir_exists
from jinja2 import (
TemplateNotFound, Environment, ChoiceLoader, FileSystemLoader, BaseLoader,
DictLoader
Expand Down Expand Up @@ -547,12 +546,11 @@ def _template_paths(self, prune=True, root_dirs=None):
compatibility_dir = os.path.join(root_dir, 'nbconvert', 'templates', 'compatibility')
paths.append(compatibility_dir)

additional_paths = self.template_data_paths
for path in additional_paths:
try:
ensure_dir_exists(path, mode=0o700)
except OSError:
pass
additional_paths = []
for path in self.template_data_paths:
if not prune or os.path.exists(path):
additional_paths.append(path)


return paths + self.extra_template_paths + additional_paths

Expand Down

0 comments on commit 3e57a03

Please sign in to comment.