Using non default branch of MFE with Tutor

Hi there. I’m running open edx olive with tutor on production. Recently we forked the learning MFE. But now when I try to use it in production with tutor I get the following error saying it’s missing python. At this point I’m just trying to use the master branch (which is not modified) instead of the named release.

275.0 npm ERR! code 1
275.0 npm ERR! path /openedx/app/node_modules/@pact-foundation/pact-core
275.0 npm ERR! command failed
275.0 npm ERR! command sh -c node-gyp rebuild
275.0 npm ERR! gyp info it worked if it ends with ok
275.0 npm ERR! gyp info using node-gyp@8.4.1
275.0 npm ERR! gyp info using node@16.14.2 | linux | x64
275.0 npm ERR! gyp ERR! find Python 
275.0 npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
275.0 npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
275.0 npm ERR! gyp ERR! find Python checking if "python3" can be used
275.0 npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
275.0 npm ERR! gyp ERR! find Python checking if "python" can be used
275.0 npm ERR! gyp ERR! find Python - executable path is "/usr/bin/python"
275.0 npm ERR! gyp ERR! find Python - version is "2.7.18"
275.0 npm ERR! gyp ERR! find Python - version is 2.7.18 - should be >=3.6.0
275.0 npm ERR! gyp ERR! find Python - THIS VERSION OF PYTHON IS NOT SUPPORTED
275.0 npm ERR! gyp ERR! find Python 
275.0 npm ERR! gyp ERR! find Python **********************************************************
275.0 npm ERR! gyp ERR! find Python You need to install the latest version of Python.
275.0 npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
275.0 npm ERR! gyp ERR! find Python you can try one of the following options:
275.0 npm ERR! gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
275.0 npm ERR! gyp ERR! find Python   (accepted by both node-gyp and npm)
275.0 npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
275.0 npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
275.0 npm ERR! gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
275.0 npm ERR! gyp ERR! find Python For more information consult the documentation at:
275.0 npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
275.0 npm ERR! gyp ERR! find Python **********************************************************
275.0 npm ERR! gyp ERR! find Python 
275.0 npm ERR! gyp ERR! configure error 
275.0 npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
275.0 npm ERR! gyp ERR! stack     at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:330:47)
275.0 npm ERR! gyp ERR! stack     at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:159:21)
275.0 npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:266:16)
275.0 npm ERR! gyp ERR! stack     at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:297:7)
275.0 npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:390:7)
275.0 npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:526:28)
275.0 npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1092:16)
275.0 npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
275.0 npm ERR! gyp ERR! System Linux 5.15.0-82-generic
275.0 npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
275.0 npm ERR! gyp ERR! cwd /openedx/app/node_modules/@pact-foundation/pact-core
275.0 npm ERR! gyp ERR! node -v v16.14.2
275.0 npm ERR! gyp ERR! node-gyp -v v8.4.1
275.0 npm ERR! gyp ERR! not ok
275.0 
275.0 npm ERR! A complete log of this run can be found in:
275.0 npm ERR!     /root/.npm/_logs/2023-09-21T00_58_30_810Z-debug-0.log
------
Dockerfile:263
--------------------
 262 |     ENV PACT_SKIP_BINARY_INSTALL=true
 263 | >>> RUN npm clean-install --no-audit --no-fund --registry=$NPM_REGISTRY \
 264 | >>>   && rm -rf ~/.npm
 265 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c npm clean-install --no-audit --no-fund --registry=$NPM_REGISTRY   && rm -rf ~/.npm" did not complete successfully: exit code: 1

After updating my tutor MFE config as follows, I just ran tutor images build mfe and got the mentioned error.

config = {
    "defaults": {
        "VERSION": __version__,
        "DOCKER_IMAGE": "{{ DOCKER_REGISTRY }}overhangio/openedx-mfe:{{ MFE_VERSION }}",
        "HOST": "apps.{{ LMS_HOST }}",
        "COMMON_VERSION": "{{ OPENEDX_COMMON_VERSION }}",
        "CADDY_DOCKER_IMAGE": "{{ DOCKER_IMAGE_CADDY }}",
        "LEARNING_MFE_APP": {
            "name": "learning",
            "repository": "https://github.com/openedx/frontend-app-learning",
            "port": 2000,
            "version": "master",
        },
        # other default mfes
    },
}

So should I do anything special for building forks and branches other than default named releases? Should I build openedx as well as mfe?
I get this same error even with the default openedx learning mfe repository on any other branch than the default named release (like master).

@FatemeKhodayari

use the CLI instead of editing config.yml directly if you did it.

tutor config save --set MFE_LEARNING_MFE_APP="{'name': 'learning', 'repository': 'https://github.com/openedx/frontend-app-learning(your fork repo path )', 'version': 'master', 'port': 2000}"

and I think not LEARNING_MFE_APP it’s MFE_LEARNING_MFE_APP. after that, u can use tutor images build --no-cache mfe or tutor images build mfe.

Unfortunately this doesn’t solve my issue. I still get the very same error. I solved (temporarily) by adding RUN apt install python-is-python3 -y to {tutor-foontprint}/env/plugins/mfe/build/mfe/Dockerfile under learning-common section.

This is not going to work. Not with tutor v16. See this section of the docs: Configuration and customisation — Tutor documentation

  • Do not try to run a fork from the edx-platform master branch: there is a 99% probability that it will fail.

The same rule applies to MFEs.

If you run Tutor v16, then you should fork your MFE from the open-release/palm.2 tag (NOT the branch). If you really, really want to run the master branch of your MFE, then you want to run Tutor nightly Running Open edX on the master branch (“nightly”) — Tutor documentation

Thanks for mentioning nightly. I’ll try and see if it raises the same error or not. About the tutor version, I’m running tutor 15.3.7.

For now, I solved the error (temporarily) by adding RUN apt install python-is-python3 -y to {tutor-foontprint}/env/plugins/mfe/build/mfe/Dockerfile under learning-common section.

Actually our main issue for forking the learning MFE was RTL and localized date time for Persian (Iran). After all the said process I realised that these issues are fixed on the master branch but not in any of the open release tags. So do you know if and when these new changes on master are going to be realeased as an stable version? Or do you know what is the right way for applying these changes? My guess is it’s happening in one of the npm packages and not directly in the learning MFE code itself.

I do not know for sure, but it’s unlikely. Typically, only bug fixes are backported from master to the release branches.

I do not know that. Let me summon @Emad, who recently did some work on Persian support.

As others mentioned, if you’re on the running tutor==15.3.7 which is Olive.4, building MFEs from the master branch will probably fail.

The right way if you don’t want a custom solution is to upgrade to palm.2 but if you need those changes, this method is a bit messy, but will work:

  • Fork your desired repository. (for example frontend-app-learning), checkout to the open-release/olive.4 tag, add your changes, create a new tag (for example khodayari-release/olive.4), and commit/push this to your forked repo.
  • Fork the tutor-mfe repository, checkout to v15.0.6 (latest tutor-mfe for olive), change the learning repo address and the tag version. commit and push.
  • Install your new tutor-mfe and run tutor config save and tutor images build mfe.

I upgraded to palm 2 (tutor 16.1.1) as you mentioned but the RTL and localization issue isn’t solved. So I guess the only way for me is using the master branch?

I’m ok with getting a branch from palm 2 and customising from there but as these changes are already applied on the master branch, do you know how these are done? Is it a library update or has direct implementation or what?

Thanks for all the help @Emad and @regis

That’s strange. Could you provide us with more guidance and clarification? I have the following questions:

  • Which language code are you using for the Persian language? It should be fa-ir, not fa.
  • Regarding the Learning mfe, I understand that RTL is not an issue, but could you please indicate some of the problems you are experiencing? (both RTL and localized date)
  • Just to confirm, are you facing difficulties after upgrading to palm.2 and building the new mfe image with tutor-mfe==16.1.1?

The language code is fa-ir. About the learning MFE, all we needed to do is customizing fonts (even in iframes), getting propper translated text (which is fine), customizing header and footer, localizing date, time and displaying everything in RTL.

Actually after the upgrade I’m facing MySQL issues about the encoding thing. But I still have not figured out the source and solution. It doesn’t happen to users with normal activities (e.g. enrollment) but happens to those who have participated in discussions, exams, assignments, etc. But the MFE build was fine.

Sorry for the late response.

all we needed to do is customizing fonts (even in iframes), getting propper translated text (which is fine), customizing header and footer, localizing date, time and displaying everything in RTL.

If you mean “course units” by “Iframes”, you need to update the font of the LMS in addition to the Learning MFE. (you can use a custom tutor-indigo theme for your LMS/CMS)

But the MFE build was fine.

Glad to hear that.

Actually after the upgrade I’m facing MySQL issues about the encoding thing.

if this is related to emojis in the short_description, I saw this in tutor issues, and will be fixed soon.

Thanks for the response.

By iframes I mean, course units (specially those with text components), dismiss-able text boxes that appear if you add anything to “updates”, etc.

I actually have an indigo-based theme in addition to the changes in learning MFE. I’m using tutor contrib branding and it’s doing almost all the work with themes and legacy frontend.

As the localization support is way better on the master branch compared to any of the release branches, I hope these changes to be released soon.

Yeah that’s the issue. Followed this issue with regis couple days a go. Thanks for mentioning though.

1 Like