Django Installed Apps Error after Quickstart on M1

Hello Everyone,

I am working on setting up my development environment on an M1 Macbook and have followed the following guide: Open edX Devstack Development with Apple Macbook M1 Silicon (ARM Architecture)

I am still using the Maple version and v13.3.1 of Tutor since we cannot make significant changes currently.

Therefore, I have built the images locally using my fork of maple.3 tag using the --build-arg argument.

I have also changed the MySQL image to MariaDB as suggested.

I can run tutor local quickstart without a problem, however, once I try to open local.overhang.io it shows Internal Server Error and the logs for lms and cms show the following problem.

Model class openedx.core.djangoapps.content_libraries.models.ContentLibrary doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
ERROR: 1

I have only found one more person with this problem here, however, it does not seem like their problem is solved: Tutor in development, error 1 import imp - #3 by Leonn - Tutor - Overhang.IO

I would like to ask if anyone has any clues as to what might have gone wrong.

I would also like to add that the exact same configuration works on an Intel Macbook.

I don’t think the problem is related to M1/ARM nor to MariaDB; it seems like a python/django installation or configuration issue.

content_libraries is a Django app plugin, so this line in setup.py should result in it being “auto-detected” by the system, and automatically added to INSTALLED_APPS. Yet for some reason it’s not in INSTALLED_APPS. Is there more context to the logs so we can see at what point the error is occurring?

I would guess at some possibilities:

  • Perhaps edx-platform is not installed correctly into the python virtual environment. From an LMS shell, in the edx-platform directory, you can try running pip install -e . and then ./manage.py lms shell to see if that resolves it.
  • Perhaps something is modifying INSTALLED_APPS and removing content_libraries. I am not sure what that would be.
  • I think the system should also generally work with content_libraries uninstalled, so I’m wondering what code is referencing the content_libraries app even though it appears to be uninstalled. Perhaps the full error message may provide more clues.
1 Like

Thank you Braden for the tips!

We will investigate these possibilities.

The first suggestion of running pip install -e . inside the LMS shell worked.

For anyone who meets this issue, the problem was simpler than that.

I bind volume a clean fork of our edx-platform to the containers instead of exporting the fork from the image, and working on the exported version of the fork.

This meant that none of the commands to build the assets, install the openedx app etc actually run on the edx-platform directory.

I dont’t quite get the solution here.

I was following this

# Run bash in the lms container
tutor dev run --mount=/path/to/edx-platform lms bash

# Compile local python requirements
pip install --requirement requirements/edx/development.txt

# Install nodejs packages in node_modules/
npm clean-install

# Rebuild static assets
openedx-assets build --env=dev

which I suppose to run within the container mounted directory but still met the same error :frowning:

Could you please explain a bit more on your solution

@tiendv89 There might be many reasons for your problem. Additionally, I am running v13.3.1 which is not the latest version and things might have changed since.

Please create a new topic with the following information:

  • Version of Tutor and Open edX you are trying to run
  • What you have done to make Tutor work on M1, in addition to the steps you have shared.
  • The exact error and the log messages

I am working with the open-release/olive.1 tag.

I have been successfully used tutor local and tutor k8s.

I am trying to learn how to set up openedx develop environment and decide to go with tutor dev.

By runnning tutor dev start -d --mount=/path/to/edx-platform lms I met the issue:
Model class openedx.core.djangoapps.content_libraries.models.ContentLibrary doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

And yes, I use a clean fork of the edx-platform and mount it to lms container.

From what I understand about your solution, I am trying to use copyfrom to copy the edx-platform on the running lms to my host machine and mount it back (however it still take long time to copy and haven’t worked out yet)

Yes, that is how I solved the problem. The copy process does take upwards of 10 minutes to complete.

1 Like

I too ran into this issue with Nutmeg release after trying to volume map directly after a quickstart or launch had provisioned.

tutor_nutmeg_dev-lms-1 | RuntimeError: Model class openedx.core.djangoapps.content_libraries.models.ContentLibrary doesn’t declare an explicit app_label and isn’t in an application in INSTALLED_APPS.

I used the docker cp | Docker Docs command to copy the default LMS Container install of edx-platform to my host machine using this command. Copying the platform directory didn’t take too long (less than a minute).

# Copy files from LMS container to Host machine
docker cp -a tutor_nutmeg_dev-lms-1:/openedx/edx-platform .

Ref: https://stackoverflow.com/questions/54213420/convert-shallow-repo-to-normal-repo 
# Unshallow the git repo (convert the shallow clone to regular one).
cd edx-platform
git fetch --unshallow

# Get access to all the branches on origin.
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch origin

I’m using Tutor from source, so I created a file at tutor/tutor/templates/dev/docker-compose.override.yml with the following volume mappings and performed a tutor config save to put this file out in the Tutor env before I issued a tutor local restart to make the volume mappings work. I followed instructions here Open edX development — Tutor documentation (overhang.io) for this mapping file.

version: "3.7"
services:
  lms:
    volumes:
      - /path/to/open-edx/tutor.dev.nutmeg/edx-platform:/openedx/edx-platform
  cms:
    volumes:
      - /path/to/open-edx/tutor.dev.nutmeg/edx-platform:/openedx/edx-platform
  lms-worker:
    volumes:
      - /path/to/open-edx/tutor.dev.nutmeg/edx-platform:/openedx/edx-platform
  cms-worker:
    volumes:
      - /path/to/open-edx/tutor.dev.nutmeg/edx-platform:/openedx/edx-platform

After a restart I verified that the RuntimeError: openedx.core.djangoapps.content_libraries went away and that the LMS and CMS pages would load properly. This seemed to work just fine.

Debugging
I set a breakpoint in the LMS Dashboard view function to see that I could breakpoint then also made sure that I was attached to the LMS Container by running the following command.

# If the LMS doesn't reload after inserting the breakpoint and saving the file, then issue the following command as indicated in this guide.
# Ref: https://docs.tutor.overhang.io/local.html#reloading-open-edx-settings
tutor dev exec lms reload-uwsgi

# Attach to the LMS Container for debugging
docker container attach tutor_nutmeg_dev-lms-1

Use a Forked edx-platform
I think from here what I’ll do is make sure that I’ll have a fork that based on this container edx-platform commits and apply our company’s specific changes. If there were any changes to models.py to ensure that migrations get applied.

It looks like I have the openedx-release/nutmeg.2 tag installed along with some patches added by the Dockerfile from openedx image. Patches came from tutor/tutor/templates/build/openedx/Dockerfile at v14.2.3 ¡ overhangio/tutor (github.com)

I created a branch titled open-release/nutmeg.install here.

cc @becdavid @traek728