How to delete non empty folder from file pane (or what am I doing wrong!)

Problem : Unable to delete a empty folder from file manager pane.

Want: In file pane, right clik on folder, select delete, read prompt, click ok, then recursivley delete.

Main Cause: Students cloning git repositories creates hidden files and nested folders

Workaround: Opening a terminal or using cell magic rm -rf <path>

Reson unsuitible (to me):
a. Unexpected bahaviour based on modern file managers and IDE behaviours
b. Expose CLI tools (rm -rf) and concepts (hidden files) to students (important to understand, but not at the moment)

Issue seems to be fixed/configurable in JupyterHub 2, but TLJH use version 1.5. Based on research (links below), solutions include.

  1. set: c.FileContentsManager.delete_to_trash = True
  2. c.Spawner.environment = {
    ‘JUPYTERHUB_SINGLEUSER_APP’: “jupyter_server.serverapp.ServerApp”

Solutions proposed (see links below) do not seem to be working for me. I have tried various combinations of both options varible, setting options using tljh_config, or creating a local config file: /opt/tljh/config/jupyterhub_config.d/ Also tried the CLI option suggested, but could not get jupyter.service to restart.

Any ideas on what I may be doing wrong? Can anyone suggest a solution?

JupyterHub Not allowing to delete non empty directory
Make it possible to delete a nonempty folders #835
Allow deleting non-empty directory when c.FileContentsManager.delete_to_trash = False #4916Jupyterhub-singleuser and jupyter_server
delete folder recursively in file explorer #9644

System Details:

  • TLJH on Ubuntu 18.04

  • jupyterhub --verison

jupyter --version

jupyter_client   : 7.0.6
jupyter_core     : 4.11.1
jupyter_server   : 1.15.6
jupyterlab       : 3.3.4
  • jupyter labextension list
JupyterLab v3.4.4
        jupyterlab-drawio v0.9.0 enabled OK (python, jupyterlab-drawio)
        jupyterlab_pygments v0.2.2 enabled OK (python, jupyterlab_pygments)
        nbdime-jupyterlab v2.1.1 enabled OK
        @jupyter-server/resource-usage v0.6.1 enabled OK (python, jupyter-resource-usage)
        @jupyterlab/git v0.38.0 enabled OK (python, jupyterlab-git)
        @pyviz/jupyterlab_pyviz v2.2.0 enabled OK (python, pyviz_comms)
        @jupyter-widgets/jupyterlab-manager v3.1.1 enabled OK (python, jupyterlab_widgets)
        @bokeh/jupyter_bokeh v3.0.4 enabled OK (python, jupyter_bokeh)

Other labextensions (built into JupyterLab)
   app dir: /usr/local/share/jupyter/lab
        @g2nb/jupyterlab-theme v0.3.1 enabled OK
        @okuzen/jupyterlab-atom-one-light v0.1.0 enabled OK
        @shahinrostami/theme-purple-please v3.0.1 enabled OK
        @yeebc/jupyterlab_neon_theme v3.1.0 enabled OK
        jupyterlab-openbayes-theme v1.0.6 enabled OK
        jupyterlab-spreadsheet v0.4.1 enabled OK
        jupyterlab-tailwind-theme v3.0.3 enabled OK
        jupyterlab-theme-solarized-dark v2.1.0 enabled OK
        jupyterlab-theme-toggle v0.6.1 enabled OK

Disabled extensions:
  • tljh-config show (reducted)
  - some-user-name
  enabled: true
    client_id: xxxxxxxxxxxxxxxxxxxxx
    client_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  type: oauthenticator.github.GitHubOAuthenticator
  default_app: jupyterlab
  memory: 4G
  cpu: 2
    enabled: true
  • cat /opt/tljh/config/jupyterhub_config.d/
c.ResourceUseDisplay.track_cpu_percent = True
c.Spawner.environment = {
    'JUPYTERHUB_SINGLEUSER_APP': "jupyter_server.serverapp.ServerApp"
c.FileContentsManager.delete_to_trash = True

This setting applies to the single-user server (Jupyter server/notebook/lab), not JupyterHub, so it’ll need to be set in your user’s environment. The configuration file depends on your single-user server, for example

Note there’s a comment in one of your links that

It looks like the issue can now be solved by setting a new parameter in Jupyter Server: FileContentsManager.always_delete_dir = True (see reference)

1 Like

Doh! I missed the link/reference (and reviewed the other posts multiple times). Thanks for the help.