NameError within Jupyter when renaming hidden files

I recently installed TLJH using the “install on own server” option. I used to be able to rename files, but when I try now, I get this error:

Traceback (most recent call last):
File "/opt/tljh/user/lib/python3.9/site-packages/tornado/", line 1704, in _execute 
	result = await result
File "/opt/tljh/user/lib/python3.9/site-packages/tornado/", line 234, in wrapper 
	yielded = ctx_run(next, result)
File "/opt/tljh/user/lib/python3.9/site-packages/notebook/services/contents/", line 135, in patch
	model = yield maybe_future(cm.update(model, path))
File "/opt/tljh/user/lib/python3.9/site-packages/notebook/services/contents/", line 296, in update
	self.rename(path, new_path)
File "/opt/tljh/user/lib/python3.9/site-packages/notebook/services/contents/", line 284, in rename
	self.rename_file(old_path, new_path)
File "/opt/tljh/user/lib/python3.9/site-packages/notebook/services/contents/", line 579, in rename_file
	raise web.HTTPError(400, f'Cannot rename file or directory {os_path!r}')
NameError: name 'os_path' is not defined

(Reformatted the traceback slightly for readability.)

I opened the file /opt/tljh/user/lib/python3.9/site-packages/notebook/services/contents/, and here’s the context of the error:

    def rename_file(self, old_path, new_path):
        """Rename a file."""
        old_path = old_path.strip('/')
        new_path = new_path.strip('/')
        if new_path == old_path:

        if (is_hidden(old_path, self.root_dir) or is_hidden(new_path, self.root_dir)) and not self.allow_hidden:
            raise web.HTTPError(400, f'Cannot rename file or directory {os_path!r}')

Sure enough, if it detects that either old path or new path is “hidden,” then it creates an exception, but the exception error message references a variable os_path. os_path is not defined, so that’s why it has a NameError.

So, here is my question:

Should I report a bug? If so, where? The best place I could figure out to report this is the jupter_server repository, which has the closest match with the code I’m looking at. The strange thing is that it has a file which nearly matches, but doesn’t have the bug.

Reading the git blame, it never had the bug, either. It only exists in the version on pypi.

Other info

How to get a copy of the code with the bug:

pip download --no-deps notebook==6.4.12
mv notebook-6.4.12-py3-none-any.whl
grep -R "Cannot rename file or directory {os_path" notebook

Versions of libraries:

(base) root@jupyter:/opt/tljh/user# pip freeze | grep jupyter

Error screenshot:

I think this is related to this post from 14 hours ago.

1 Like