Infinite 'watchthemes' compile loop

Hi all.

I’ve been working on devstack for a while, but I reinstalled the tutor. I’m running into a problem I haven’t encountered before. When I create a custom theme, when I add anything to the styles, watchthemes goes into an endless compilation loop. I can see the changes I made in css/lms-main-v1.css, but it keeps recompiling. After a while cpu and ram are 200-300% and the computer freezes. I have never encountered such a problem before. After installing the latest version, I encounter such a problem. Can you help?

tutor, version 17.0.4

1 Like

happened every version

Has this problem occurred after a new update? It was working fine before.

I’ve had the same issue - I couldn’t debug, but looks to be some sort of memory leak.

I had trouble with tutor config save copying all the theme files across in one go, overwriting existing even when identical, which then causes the compilation loop.

This can be a problem when restarting the dev environment as if you’ve previously run watchthemes and the container’s been built it will spin up on every tutor dev start / tutor dev restart all / tutor dev launch.

A bit of a pain but you can get the docker container id, and stop it once you’ve spun up tutor.

You can then re-run watchthemes when you need it.

To copy only updated files env/build/openedx/themes directory I made a script:


# Define the source and target directories

# Make sure inotifywait and rsync are installed
if ! command -v inotifywait &> /dev/null || ! command -v rsync &> /dev/null
    echo "inotifywait and rsync are required for this script to run."
    exit 1

# Function to synchronise the changed file or delete it if necessary
sync_or_delete_file() {
    local event_type="$1"
    local source_directory="$2"
    local file_name="$3"
    local relative_directory="${source_directory//$SOURCE_DIR/}"
    echo "Relative dir: $relative_directory"

    if [[ "$event_type" == *"DELETE"* || "$event_type" == *"MOVED_FROM"* ]]; then
        # If the file was deleted or moved from, delete it from the target
        local target_file="${TARGET_DIR}/${file_name}"
        rm -f "$target_file"
        echo "File deleted: $target_file at $(date)"
        # For other events, use rsync to synchronise the specific file
        local source_file="${source_directory}${file_name}"
        local target_file_dir="$(dirname "${TARGET_DIR}${relative_directory}/${file_name}")"
        mkdir -p "$target_file_dir" # Ensure target directory exists
        rsync -av "$source_file" "$target_file_dir"
        echo "File synchronised: $source_file to $target_file_dir at $(date)"

# Watch for changes in the source directory and act on them
inotifywait -m -r -e modify,create,delete,move "$SOURCE_DIR" --format '%:e %w %f' |
while IFS=' ' read -r event directory file; do
    # Filter out events that are not directly related to file changes
    if [[ "$event" == "CREATE,ISDIR" || "$event" == "MODIFY,ISDIR" ]]; then
        continue # Skip directory-related events for now
    # For move events, adjust to capture the destination file name
    if [[ "$event" == "MOVED_TO" || "$event" == "MOVED_FROM" ]]; then
        read -r additional_event additional_file
        if [[ "$additional_event" == "MOVED_TO" && "$event" == "MOVED_FROM" ]]; then
            file="$additional_file" # Use the destination file name
    echo "Dir: $directory"

    sync_or_delete_file "$event" "$directory" "$file"
1 Like

Thanks for answer.

Actually, so did i like your said;

I stoped watchthemes tutor dev stop watchthemes after the tutor dev start then, when changes some style and run tutor dev run watchthemes. Yes, this method works but if don’t stop this watchthemes just in time, it is entering the infinite loop again and to be hard for stop the container with this method.

Do you know of a manual method for compiling the SCSS files?

No problem. You can use the following instead of watchthemes. It’s a pain to have to manually trigger it, but it’s better than a container with a memory leak!

Compiling themes’ SCSS:

tutor dev run lms ./ lms compile_sass

Collecting static build assets:

tutor dev run lms ./ lms collectstatic --noinput && ./ cms collectstatic --noinput

I came across them here


These are very useful for me for now. I don’t know how I didn’t come across this link before. Thanks so much for your help

No worries! Some of these things are quite well hidden :sweat_smile:

Yes, I agree about hiding :smile: If you hadn’t told me, I probably wouldn’t have found this link.