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

**URL:** <https://discourse.jupyter.org/t/how-to-delete-non-empty-folder-from-file-pane-or-what-am-i-doing-wrong/15244>\
**Category:** The Littlest JupyterHub\
**Created:** [August 6, 2022, 12:40am UTC](https://discourse.jupyter.org/t/how-to-delete-non-empty-folder-from-file-pane-or-what-am-i-doing-wrong/15244 "2022-08-06T00:40:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bricklemacho](https://avatars.discourse-cdn.com/v4/letter/b/34f0e0/32.png) [@bricklemacho](https://discourse.jupyter.org/u/bricklemacho)\
**Post date:** [August 6, 2022, 12:40am UTC](https://discourse.jupyter.org/t/how-to-delete-non-empty-folder-from-file-pane-or-what-am-i-doing-wrong/15244/1 "2022-08-06T00:40:49Z")

</div>

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/local\_settings.py. 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?

Similar/Same:  
[JupyterHub Not allowing to delete non empty directory](https://discourse.jupyter.org/t/jupyterhub-not-allowing-to-delete-non-empty-directory/8539)  
[Make it possible to delete a nonempty folders #835](https://github.com/jupyterlab/jupyterlab/issues/835)  
[Allow deleting non-empty directory when c.FileContentsManager.delete\_to\_trash = False #4916](https://github.com/jupyter/notebook/issues/4916)[Jupyterhub-singleuser and jupyter\_server](https://discourse.jupyter.org/t/jupyterhub-singleuser-and-jupyter-server/10942)  
[delete folder recursively in file explorer #9644](https://github.com/jupyterlab/jupyterlab/issues/9644)

System Details:

- TLJH on Ubuntu 18.04

- `jupyterhub --verison`  
`1.5.0`

`jupyter --version`

```auto
jupyter_client : 7.0.6
jupyter_core : 4.11.1
jupyter_server : 1.15.6
jupyterlab : 3.3.4

```

- `jupyter labextension list`

```auto
JupyterLab v3.4.4
/usr/local/share/jupyter/labextensions
        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:
    @jupyterlab/application-extension:logo

```

- `tljh-config show` (reducted)

```auto
users:
  admin:
  - some-user-name
https:
  enabled: true
  letsencrypt:
    email: user@example.com
    domains:
    - example.com
auth:
  GitHubOAuthenticator:
    client_id: xxxxxxxxxxxxxxxxxxxxx
    client_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    oauth_callback_url: https://example.com/hub/oauth_callback
  type: oauthenticator.github.GitHubOAuthenticator
user_environment:
  default_app: jupyterlab
limits:
  memory: 4G
  cpu: 2
services:
  configurator:
    enabled: true

```

- `cat /opt/tljh/config/jupyterhub_config.d/local_settings.py`

```auto
c.ResourceUseDisplay.track_cpu_percent = True
c.Spawner.environment = {
    'JUPYTERHUB_SINGLEUSER_APP': "jupyter_server.serverapp.ServerApp"
}
c.FileContentsManager.delete_to_trash = True

```

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [August 8, 2022, 2:25pm UTC](https://discourse.jupyter.org/t/how-to-delete-non-empty-folder-from-file-pane-or-what-am-i-doing-wrong/15244/2 "2022-08-08T14:25:33Z")

</div>

> [@bricklemacho](#):
>
> `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  
[https://docs.jupyter.org/en/latest/use/jupyter-directories.html#configuration-files](https://docs.jupyter.org/en/latest/use/jupyter-directories.html#configuration-files)

Note there’s a [comment in one of your links](https://github.com/jupyter/notebook/issues/4916#issuecomment-1204282630) 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](https://jupyter-server.readthedocs.io/en/latest/other/full-config.html))

---

<div class="post-metadata">

**Author:** ![bricklemacho](https://avatars.discourse-cdn.com/v4/letter/b/34f0e0/32.png) [@bricklemacho](https://discourse.jupyter.org/u/bricklemacho)\
**Post date:** [August 9, 2022, 2:18am UTC](https://discourse.jupyter.org/t/how-to-delete-non-empty-folder-from-file-pane-or-what-am-i-doing-wrong/15244/3 "2022-08-09T02:18:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![danifr](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/danifr/32/19316_2.png) [@danifr](https://discourse.jupyter.org/u/danifr)\
**Post date:** [July 4, 2025, 9:18am UTC](https://discourse.jupyter.org/t/how-to-delete-non-empty-folder-from-file-pane-or-what-am-i-doing-wrong/15244/4 "2025-07-04T09:18:45Z")

</div>

Apologies for resurrecting this topic but it is still unclear to me how to do this from tljh.

Only way I found so far is to add `self.config.FileContentsManager.always_delete_dir = True` to /opt/tljh/user/lib/python3.12/site-packages/jupyterhub/singleuser/extension.py but it feels too hacky.

@manics do you know if there a better way of doing it? can I overwrite single-user server’s config from one of those .py files under /opt/tljh/config/jupyterhub\_config.d/?

thank you very much,  
Daniel

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [July 6, 2025, 1:14pm UTC](https://discourse.jupyter.org/t/how-to-delete-non-empty-folder-from-file-pane-or-what-am-i-doing-wrong/15244/5 "2025-07-06T13:14:08Z")

</div>

Your Jupyter server configuration files are independent of the JupyterHub config. See

> **[Common Directories and File Locations — Jupyter Documentation 4.1.1 alpha...](https://docs.jupyter.org/en/stable/use/jupyter-directories.html)**

For the possible locations

---

<div class="post-metadata">

**Author:** ![danifr](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/danifr/32/19316_2.png) [@danifr](https://discourse.jupyter.org/u/danifr)\
**Post date:** [July 7, 2025, 12:33pm UTC](https://discourse.jupyter.org/t/how-to-delete-non-empty-folder-from-file-pane-or-what-am-i-doing-wrong/15244/6 "2025-07-07T12:33:02Z")

</div>

Thanks for the answer, it would be great if TLJH had something built-in to configure Jupyter server.

In a similar way “Zero to JupyterHub with Kubernetes” does it: [Recursive delete directories in file browser? - #3 by cboettig](https://discourse.jupyter.org/t/recursive-delete-directories-in-file-browser/27468/3)

---

<div class="post-metadata">

**Author:** ![danifr](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/danifr/32/19316_2.png) [@danifr](https://discourse.jupyter.org/u/danifr)\
**Post date:** [July 8, 2025, 6:38am UTC](https://discourse.jupyter.org/t/how-to-delete-non-empty-folder-from-file-pane-or-what-am-i-doing-wrong/15244/7 "2025-07-08T06:38:35Z")

</div>

For completeness, if you are using TLJH you need to add:

```auto
{
  "FileContentsManager":
  { 
    "always_delete_dir": true
  }
}

```

to: `/opt/tljh/user/etc/jupyter/jupyter_server_config.json`
