Repost of Custom xblock won’t install in Tutor dev

Hello everyone!

This message is a repost from the Tutor Discuss site (Custom xblock won't install in dev - Tutor - Overhang.IO). I thought it was worth posting here to help developers facing the same problem because the other site is deprecated.

At the time of this post, there is no known documentation (or easy-to-find documentation) on how Open edX discovers XBlocks in Tutor dev mode.

Problem: The problem is that XBlocks installed from the requirements.txt file are accessible in Open edX production mode but might not be accessible in development mode

Cause: The problem documented on by michael and ToddLichty is that XBlocks running in Tutor dev require a .egg-info folder so that they are discoverable. Otherwise, Open edX will not show the XBlocks in the Advanced component.

Solution: The solution is to generate the missing .egg-info folder for the XBlock before starting Tutor in dev mode.

# install and create the virtual environment
sudo apt install python3-venv
python3.8 -m venv ~/venv3.8

# enter the virual env
source ~/venv3.8/bin/activate

# cd to xblock dev directory
# cd $(tutor config printroot)/env/build/openedx/requirements/xblock_dev

# Generate the .egg-info folder
sudo python3 develop

# leave the virtual env

Replication: You can replicate the problem of missing XBlocks in In Tutor version 14.0.4 dev mode by cloning the edx_sga XBlock from GitHub - mitodl/edx-sga: Staff Graded Assignment XBlock for the edX platform and installing it from the requirements.txt file. The project is missing the .egg-info folder.

The XBlock will show in the Advanced component box in production but not in dev. It will only display once you generate the .egg-info folder and then relaunch the development platform.

I hope that this will help others facing the same problem!