I am trying to run an image from this repository (Dockerfile-based):
on mybinder. I need to use Dockerfile because I am trying to run a legacy project that it’s not working with recent jupyter notebook versions. Therefore I download old anaconda distribution, that I know is compatible with my notebook. I use the instructions from binderhub to create the dockerfile. The image builts and runs fine on my machine. It’s also builit sucessfully on mybinder, but when I try to launch it, I get “500 Internal server error”. I tried a few modifications (install dirs, user permissions etc.) in the Dockerfile, but the result is always the same.
I tried also running the repo with my private deployment of binderhub (setup using the instructions from “Zero to BinderHub”), and the image builds/runs fine (temporary link, that will stop working soon):
Running repo2docker master branch locally works fine. It opens a jupyter notebook with a directory tree.
From the logs I see that mybinder instance crashes on rendering a jinja2 template. Apparently, there is a problem with the template in file "/etc/jupyter/templates/tree.html
I have no idea, where this template comes from. In the image built locally with repo2docker this file does not even exist. Any ideas?
If you have a moment to investigate a bit further and maybe make a suggestion what we can do or even make a PR that would be super!
We recently changed the templates to add buttons to the top right of the UI to help people with sharing their Binders. People used to share the wrong link which lead to confused people when they followed them.
It seems that the internationalization ({% trans %} tag) was introduced in notebook 5.1. I upgraded from 5.0 to 5.1 and it works perfectl! Thanks a lot for help!
There are not many solutions to make the template compatible with notebooks prior to 5.1:
remove internationalization (but I guess not an option),
patch jupyter < 5.1 to add jinja2 i18n extension – not maintainable,
mention that notebook > 5.1 is required in the docs
Unfortunately, I don’t find any way to make the {% trans %} tag conditional, i.e. only include it in the template if the extension is loaded.
Alternatively, one could modify mybinder deployment scripts to inject the templates only for notebook >= 5.1 (or inject a different version for notebook < 5.1).
Can we detect (reliably) the version of the notebook server in a jupyter config file? Then we could put the templates in a new directory that isn’t on the search path by default and for notebook > v5 we add that path to the search path? So it is a opt-in for “new enough” versions.
Thanks for helping out with ideas and actually trying stuff!
I just opened a PR 1247 with the resolution to the issue.
The solution proved to be very simple. I found an option in jupyter_notebook_config that allows to inject variables into jinja environment. With this option, one can add the i18n extension to jinja templates in notebooks prior to 5.1.0 (tested with 5.0.0). QED