No customisable menu in nbextension menu_snippets

Hello there,

I am trying to include a customised menu in jupyter notebooks using menu_snippets. Anyhow, when I put example code in the custom.js, I do not get any additional menu after refreshing my jupyter notebooks.

  • I was trying to create a customised menu using the custom.js file such that I could see an additional menu in my toolbar.
  • I expected to see a menu labeled “My favorites” in the toolbar.
  • Anyhow, I do not see that menu, even though I can see the snippet menu and use it, indicating that the extension installs and is enabled.
  • Error messages I receive:
    • When launching jupyter-notebooks: [W 12:54:30.919 NotebookApp] 404 GET /nbextensions/nbextensions_configurator/tree_tab/main.js?v=20230317125426 (127.0.0.1) 9.610000ms referer=http://localhost:8888/tree

I have tried different ways and also inspected the main.js in jupyter_boilerplate, but could not find a way out of this. Do you have any ideas what I can do to make the custom.js do its magic?

How did I get that error?

  1. installed jupyter-notebooks via pip install jupyter
  2. It is likely that I installed nbextensions, since the folder jupyter/nbextensions existed when I executed 3.a, but I cannot verify how that happened anymore.
  3. installed menu_snippets using:
  • a cd $(jupyter --data-dir)/nbextensions
  • b git clone https://github.com/moble/jupyter_boilerplate
  • c jupyter nbextension install jupyter_boilerplate --user
  • d jupyter nbextension enable jupyter_boilerplate/main --user
  1. used custom.js in ~/.jupyter/custom/custom.js and added the following code:
require(["nbextensions/snippets_menu/main"], function (snippets_menu) {
    console.log('Loading `snippets_menu` customizations from `custom.js`');
    var horizontal_line = '---';
    var my_favorites = {
        'name' : 'My favorites',
        'sub-menu' : [
            {
                'name' : 'Menu item text',
                'snippet' : ['new_command(3.14)',],
            },
            {
                'name' : 'Another menu item',
                'snippet' : ['another_new_command(2.78)',],
            },
        ],
    };
    snippets_menu.options['menus'] = snippets_menu.default_menus;
    snippets_menu.options['menus'][0]['sub-menu'].push(horizontal_line);
    snippets_menu.options['menus'][0]['sub-menu'].push(my_favorites);
    console.log('Loaded `snippets_menu` customizations from `custom.js`');
});

  1. When refreshing jupyter-notebooks, I now see the Snippets-Menu, but no additional menu as I should and also no subsequent sub menu.

Environment

  • Operating system: 5.19.0-35-generic #36~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Feb 17 15:17:25 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
  • Browser software version: Firefox Snap for Ubuntu, 110.0.1 (64-bit)

Ideas

  • The error in the console when starting jupyter-notebooks makes me suspicious, even though having the Snippets-menu in jupyter notebooks indicates that it has been loaded
  • I am having some confusion with the snippets_menu extension as well as the jupyter_boilerplate extension and what goes where. So could it be a confusion with names that led me to my error? Since the custom.js is neither in /snippets_menu nor /jupyter_boilerplate, I would think it would work regardless of my confusion.

I would be grateful if you have a solution for that or have an idea on how to fix that issue.

Best