Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting notebooks is broken #3249

Closed
jdemeyer opened this issue Jan 23, 2018 · 3 comments · Fixed by #3304
Closed

Deleting notebooks is broken #3249

jdemeyer opened this issue Jan 23, 2018 · 3 comments · Fixed by #3304

Comments

@jdemeyer
Copy link
Contributor

With Jupyter notebook 5.3.1, I can no longer delete notebook files:

[E 11:16:58.653 NotebookApp] Uncaught exception DELETE /api/contents/Untitled2.ipynb (::1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='DELETE', uri='/api/contents/Untitled2.ipynb', version='HTTP/1.1', remote_ip='::1', headers={'Accept-Language': 'nl,en;q=0.5', 'Accept-Encoding': 'gzip, deflate', 'X-Xsrftoken': '2|53abba32|97dda7043bc73dc31a6c8b157cfbc04a|1515155636', 'Host': 'localhost:8888', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0', 'Connection': 'keep-alive', 'X-Requested-With': 'XMLHttpRequest', 'Referer': 'http://localhost:8888/tree', 'Cookie': 'username-localhost-8888="2|1:0|10:1516702258|23:username-localhost-8888|44:MjY1ODA5Njc1NzVlNDZmYmFjYTZlMjkxNDI4ZDM4Yzg=|6b2a4bb9ff2376377b714716929ddda9943e239553d9ebbb381de8de9c60162e"; _xsrf=2|53abba32|97dda7043bc73dc31a6c8b157cfbc04a|1515155636; username-localhost-8889="2|1:0|10:1516109384|23:username-localhost-8889|44:ODFmNjM5YjBkYmQ5NDFiZmE3NWUyYmMzZjUxOTM4MTM=|c76b2846927ce1ac607b0d7da30f7a6c254cbc251d82c43cb316c26622c8f765"'})
    Traceback (most recent call last):
      File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/tornado/web.py", line 1511, in _execute
        result = yield result
      File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/tornado/gen.py", line 1055, in run
        value = future.result()
      File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/tornado/concurrent.py", line 238, in result
        raise_exc_info(self._exc_info)
      File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/tornado/gen.py", line 307, in wrapper
        yielded = next(result)
      File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/notebook/services/contents/handlers.py", line 235, in delete
        yield gen.maybe_future(cm.delete(path))
      File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/notebook/services/contents/manager.py", line 278, in delete
        self.delete_file(path)
      File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/notebook/services/contents/filemanager.py", line 499, in delete_file
        send2trash(os_path)
      File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/send2trash/plat_other.py", line 185, in send2trash
        dest_trash = find_ext_volume_trash(topdir)
      File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/send2trash/plat_other.py", line 145, in find_ext_volume_trash
        trash_dir = find_ext_volume_fallback_trash(volume_root)
      File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/send2trash/plat_other.py", line 139, in find_ext_volume_fallback_trash
        check_create(trash_dir)
      File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/send2trash/plat_other.py", line 84, in check_create
        os.makedirs(dir, 0o700)
      File "/usr/local/src/sage-config/local/lib/python2.7/os.py", line 157, in makedirs
        mkdir(name, mode)
    OSError: [Errno 13] Permission denied: '/.Trash-1038'

This worked fine in notebook 5.2.2

@takluyver
Copy link
Member

What's the path of the notebook, and can you try running this code?

import os
path = b'/path/to/Notebook.ipynb'  # Replace with real path
while True:
    print(path)
    print(os.stat(path))
    if path == b'/':
        break
    path = os.path.dirname(path)

See also #3130.

@jdemeyer
Copy link
Contributor Author

In [1]: import os
   ...: path = b'/usr/local/src/sage-config/Untitled.ipynb'
   ...: while True:
   ...:     print(path)
   ...:     print(os.stat(path))
   ...:     if path == b'/':
   ...:         break
   ...:     path = os.path.dirname(path)
   ...:     
/usr/local/src/sage-config/Untitled.ipynb
posix.stat_result(st_mode=33188, st_ino=2643752, st_dev=2054, st_nlink=1, st_uid=1038, st_gid=1038, st_size=72, st_atime=1516721474, st_mtime=1516721474, st_ctime=1516721474)
/usr/local/src/sage-config
posix.stat_result(st_mode=16877, st_ino=2626885, st_dev=2054, st_nlink=12, st_uid=1038, st_gid=1038, st_size=12288, st_atime=1386837610, st_mtime=1516721839, st_ctime=1516721839)
/usr/local/src
posix.stat_result(st_mode=16877, st_ino=2625283, st_dev=2054, st_nlink=7, st_uid=1038, st_gid=1038, st_size=4096, st_atime=1364130939, st_mtime=1497615312, st_ctime=1497615312)
/usr/local
posix.stat_result(st_mode=16877, st_ino=2501391, st_dev=2054, st_nlink=11, st_uid=0, st_gid=0, st_size=4096, st_atime=1345649702, st_mtime=1462960076, st_ctime=1462960076)
/usr
posix.stat_result(st_mode=16877, st_ino=2359297, st_dev=2054, st_nlink=15, st_uid=0, st_gid=0, st_size=4096, st_atime=1345650358, st_mtime=1458498174, st_ctime=1458499227)
/
posix.stat_result(st_mode=16877, st_ino=2, st_dev=2054, st_nlink=21, st_uid=0, st_gid=0, st_size=4096, st_atime=1345655355, st_mtime=1507391001, st_ctime=1507391001)

@technic
Copy link

technic commented Jan 11, 2019

I am not satisfied with the solution. I have a docker container with ~/work mounted from the host machine, but ~/ is in the container filesystem. Current solutions force removes files, which can be harmful in case of accident remove. The send2trash command works fine though and creates ~/work/.Trash-1000. I would suggest to try send2trash every time, but if it fails show a popup dialog to confirm force removal.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants