Repository: itzg/docker-minecraft-server

Issue #2530: REMOVE_OLD_MODS deletes all mods downloaded by MODRINTH_MODPACK
Created: 2023-12-05T23:10:51Z
Describe the problem
When REMOVE_OLD_MODS is set to true and the Option MODRINTH_MODPACK is used to download mods, the mods are getting deleted before the server starts resulting in the server starting without mods.
Container definition
version: "1.0"

services:
  cb:
    container_name: cb
    image: itzg/minecraft-server:latest
    restart: unless-stopped
    tty: true
    stdin_open: true
    environment:
      VERSION: 1.20.1
      MOD_PLATFORM: MODRINTH
      MODRINTH_MODPACK: https://modrinth.com/modpack/cobblemon-fabric/version/1.4.0.1
      MODRINTH_EXCLUDE_FILES: |
        betterpingdisplay
      UID: 1000
      GID: 1000
      EULA: "TRUE"
      TZ: "Europe/Berlin"
      INIT_MEMORY: 4G
      MAX_MEMORY: 8G
      DIFFICULTY: normal
      OPS: user
      MOTD: "Hi!"
      PVP: "FALSE"
      SPAWN_PROTECTION: 0
      ICON: https://cdn.modrinth.com/data/MdwFAVRL/e54083a07bcd9436d1f8d2879b0d821a54588b9e.png
      MAX_PLAYERS: 20
      ENABLE_WHITELIST: "TRUE"
      WHITELIST_FILE: /home/hades/minecraft/cb/whitelist.json
      REMOVE_OLD_MODS: "TRUE"
      REPLACE_ENV_VARIABLES: "TRUE"
    ports:
      - 25565:25565
    volumes:
      - /home/hades/minecraft/cb:/data

Container logs
[mc-image-helper] 23:40:13.625 INFO  : Downloaded mods/RoughlyEnoughItems-12.0.665.jar
[mc-image-helper] 23:40:13.894 INFO  : Downloaded mods/Xaeros_Minimap_23.8.2_Fabric_1.20.jar
[mc-image-helper] 23:40:14.500 INFO  : Downloaded mods/fabric-language-kotlin-1.10.10+kotlin.1.9.10.jar
[mc-image-helper] 23:40:14.582 INFO  : Downloaded mods/PresenceFootsteps-1.9.0.jar
[mc-image-helper] 23:40:20.761 INFO  : Downloaded mods/Cobblemon-fabric-1.4.0+1.20.1.jar
[mc-image-helper] 23:40:21.837 INFO  : Fabric launcher for minecraft 1.20.1 loader 0.14.23 is already available
[init] Removing old mods including:*.jar,*-version.json excluding:
[init] Enabling whitelist functionality
[mc-image-helper] 23:40:25.834 INFO  : Created/updated 1 property in /data/server.properties
[init] Replacing env variables in /data that match the prefix 'CFG_' ...
[mc-image-helper] 23:40:27.636 INFO  : The file ./ops.json already exists, so no changes will be made
[mc-image-helper] 23:40:28.611 INFO  : The file ./whitelist.json already exists, so no changes will be made
[init] Using server icon from https://cdn.modrinth.com/data/MdwFAVRL/e54083a07bcd9436d1f8d2879b0d821a54588b9e.png...
[init] Converting image to 64x64 PNG...
[init] Setting initial memory to 4G and max to 8G
[init] Starting the Minecraft server...
Downloading Minecraft server
Installing Fabric Loader 0.14.23(1.20.1) on the server
Downloading required files
Downloading library net.fabricmc:tiny-mappings-parser:0.3.0+build.17
Downloading library net.fabricmc:sponge-mixin:0.12.5+mixin.0.8.5
Downloading library net.fabricmc:tiny-remapper:0.8.2
Downloading library net.fabricmc:access-widener:2.1.0
Downloading library org.ow2.asm:asm:9.6
Downloading library org.ow2.asm:asm-analysis:9.6
Downloading library org.ow2.asm:asm-commons:9.6
Downloading library org.ow2.asm:asm-tree:9.6
Downloading library org.ow2.asm:asm-util:9.6
Downloading library net.fabricmc:intermediary:1.20.1
Downloading library net.fabricmc:fabric-loader:0.14.23
Generating server launch JAR
Unpacking 1.20.1/server-1.20.1.jar (versions:1.20.1) to versions/1.20.1/server-1.20.1.jar
Unpacking com/github/oshi/oshi-core/6.2.2/oshi-core-6.2.2.jar (libraries:com.github.oshi:oshi-core:6.2.2) to libraries/com/github/oshi/oshi-core/6.2.2/oshi-core-6.2.2.jar
Unpacking com/google/code/gson/gson/2.10/gson-2.10.jar (libraries:com.google.code.gson:gson:2.10) to libraries/com/google/code/gson/gson/2.10/gson-2.10.jar
Unpacking com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar (libraries:com.google.guava:failureaccess:1.0.1) to libraries/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar
Unpacking com/google/guava/guava/31.1-jre/guava-31.1-jre.jar (libraries:com.google.guava:guava:31.1-jre) to libraries/com/google/guava/guava/31.1-jre/guava-31.1-jre.jar
Unpacking com/mojang/authlib/4.0.43/authlib-4.0.43.jar (libraries:com.mojang:authlib:4.0.43) to libraries/com/mojang/authlib/4.0.43/authlib-4.0.43.jar
Unpacking com/mojang/brigadier/1.1.8/brigadier-1.1.8.jar (libraries:com.mojang:brigadier:1.1.8) to libraries/com/mojang/brigadier/1.1.8/brigadier-1.1.8.jar
Unpacking com/mojang/datafixerupper/6.0.8/datafixerupper-6.0.8.jar (libraries:com.mojang:datafixerupper:6.0.8) to libraries/com/mojang/datafixerupper/6.0.8/datafixerupper-6.0.8.jar
Unpacking com/mojang/logging/1.1.1/logging-1.1.1.jar (libraries:com.mojang:logging:1.1.1) to libraries/com/mojang/logging/1.1.1/logging-1.1.1.jar
Unpacking commons-io/commons-io/2.11.0/commons-io-2.11.0.jar (libraries:commons-io:commons-io:2.11.0) to libraries/commons-io/commons-io/2.11.0/commons-io-2.11.0.jar
Unpacking io/netty/netty-buffer/4.1.82.Final/netty-buffer-4.1.82.Final.jar (libraries:io.netty:netty-buffer:4.1.82.Final) to libraries/io/netty/netty-buffer/4.1.82.Final/netty-buffer-4.1.82.Final.jar
Unpacking io/netty/netty-codec/4.1.82.Final/netty-codec-4.1.82.Final.jar (libraries:io.netty:netty-codec:4.1.82.Final) to libraries/io/netty/netty-codec/4.1.82.Final/netty-codec-4.1.82.Final.jar
Unpacking io/netty/netty-common/4.1.82.Final/netty-common-4.1.82.Final.jar (libraries:io.netty:netty-common:4.1.82.Final) to libraries/io/netty/netty-common/4.1.82.Final/netty-common-4.1.82.Final.jar
Unpacking io/netty/netty-handler/4.1.82.Final/netty-handler-4.1.82.Final.jar (libraries:io.netty:netty-handler:4.1.82.Final) to libraries/io/netty/netty-handler/4.1.82.Final/netty-handler-4.1.82.Final.jar
Unpacking io/netty/netty-resolver/4.1.82.Final/netty-resolver-4.1.82.Final.jar (libraries:io.netty:netty-resolver:4.1.82.Final) to libraries/io/netty/netty-resolver/4.1.82.Final/netty-resolver-4.1.82.Final.jar
Unpacking io/netty/netty-transport/4.1.82.Final/netty-transport-4.1.82.Final.jar (libraries:io.netty:netty-transport:4.1.82.Final) to libraries/io/netty/netty-transport/4.1.82.Final/netty-transport-4.1.82.Final.jar
Unpacking io/netty/netty-transport-classes-epoll/4.1.82.Final/netty-transport-classes-epoll-4.1.82.Final.jar (libraries:io.netty:netty-transport-classes-epoll:4.1.82.Final) to libraries/io/netty/netty-transport-classes-epoll/4.1.82.Final/netty-transport-classes-epoll-4.1.82.Final.jar
Unpacking io/netty/netty-transport-native-epoll/4.1.82.Final/netty-transport-native-epoll-4.1.82.Final-linux-x86_64.jar (libraries:io.netty:netty-transport-native-epoll:4.1.82.Final:linux-x86_64) to libraries/io/netty/netty-transport-native-epoll/4.1.82.Final/netty-transport-native-epoll-4.1.82.Final-linux-x86_64.jar
Unpacking io/netty/netty-transport-native-epoll/4.1.82.Final/netty-transport-native-epoll-4.1.82.Final-linux-aarch_64.jar (libraries:io.netty:netty-transport-native-epoll:4.1.82.Final:linux-aarch_64) to libraries/io/netty/netty-transport-native-epoll/4.1.82.Final/netty-transport-native-epoll-4.1.82.Final-linux-aarch_64.jar
Unpacking io/netty/netty-transport-native-unix-common/4.1.82.Final/netty-transport-native-unix-common-4.1.82.Final.jar (libraries:io.netty:netty-transport-native-unix-common:4.1.82.Final) to libraries/io/netty/netty-transport-native-unix-common/4.1.82.Final/netty-transport-native-unix-common-4.1.82.Final.jar
Unpacking it/unimi/dsi/fastutil/8.5.9/fastutil-8.5.9.jar (libraries:it.unimi.dsi:fastutil:8.5.9) to libraries/it/unimi/dsi/fastutil/8.5.9/fastutil-8.5.9.jar
Unpacking net/java/dev/jna/jna/5.12.1/jna-5.12.1.jar (libraries:net.java.dev.jna:jna:5.12.1) to libraries/net/java/dev/jna/jna/5.12.1/jna-5.12.1.jar
Unpacking net/java/dev/jna/jna-platform/5.12.1/jna-platform-5.12.1.jar (libraries:net.java.dev.jna:jna-platform:5.12.1) to libraries/net/java/dev/jna/jna-platform/5.12.1/jna-platform-5.12.1.jar
Unpacking net/sf/jopt-simple/jopt-simple/5.0.4/jopt-simple-5.0.4.jar (libraries:net.sf.jopt-simple:jopt-simple:5.0.4) to libraries/net/sf/jopt-simple/jopt-simple/5.0.4/jopt-simple-5.0.4.jar
Unpacking org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar (libraries:org.apache.commons:commons-lang3:3.12.0) to libraries/org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar
Unpacking org/apache/logging/log4j/log4j-api/2.19.0/log4j-api-2.19.0.jar (libraries:org.apache.logging.log4j:log4j-api:2.19.0) to libraries/org/apache/logging/log4j/log4j-api/2.19.0/log4j-api-2.19.0.jar
Unpacking org/apache/logging/log4j/log4j-core/2.19.0/log4j-core-2.19.0.jar (libraries:org.apache.logging.log4j:log4j-core:2.19.0) to libraries/org/apache/logging/log4j/log4j-core/2.19.0/log4j-core-2.19.0.jar
Unpacking org/apache/logging/log4j/log4j-slf4j2-impl/2.19.0/log4j-slf4j2-impl-2.19.0.jar (libraries:org.apache.logging.log4j:log4j-slf4j2-impl:2.19.0) to libraries/org/apache/logging/log4j/log4j-slf4j2-impl/2.19.0/log4j-slf4j2-impl-2.19.0.jar
Unpacking org/joml/joml/1.10.5/joml-1.10.5.jar (libraries:org.joml:joml:1.10.5) to libraries/org/joml/joml/1.10.5/joml-1.10.5.jar
Unpacking org/slf4j/slf4j-api/2.0.1/slf4j-api-2.0.1.jar (libraries:org.slf4j:slf4j-api:2.0.1) to libraries/org/slf4j/slf4j-api/2.0.1/slf4j-api-2.0.1.jar
Starting net.fabricmc.loader.impl.game.minecraft.BundlerClassPathCapture
[23:40:46] [main/INFO]: Loading Minecraft 1.20.1 with Fabric Loader 0.14.23
[23:40:46] [main/INFO]: Fabric is preparing JARs on first launch, this may take a few seconds...
[23:40:46] [main/INFO]: Loading 3 mods:
	- fabricloader 0.14.23
	- java 17
	- minecraft 1.20.1
[23:40:46] [main/INFO]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=file:/data/libraries/net/fabricmc/sponge-mixin/0.12.5+mixin.0.8.5/sponge-mixin-0.12.5+mixin.0.8.5.jar Service=Knot/Fabric Env=SERVER
[23:40:52] [main/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
[23:40:53] [main/INFO]: Loaded 7 recipes
[23:40:53] [main/INFO]: Loaded 1271 advancements
[23:40:54] [Server thread/INFO]: Starting minecraft server version 1.20.1```

Duplicate issue #2583: REMOVE_OLD_MODS overzealous
Created: 2024-01-08T03:03:32Z
Describe the problem
Starting with a directory containing three files:
.env includes the CF_API_KEY as usual
compose.yml (below), and
manifest.json (below)
Container definition
services:
  mc:
    image: itzg/minecraft-server:java8-multiarch
    environment:
      EULA: true
      MOD_PLATFORM: AUTO_CURSEFORGE
      CF_API_KEY: ${CF_API_KEY}
      FORGE_VERSION: "14.23.5.2860"
      VERSION: 1.12.2

      REMOVE_OLD_MODS: "true"

      CF_MODPACK_MANIFEST: /manifest.json
      CF_SLUG: "custom"
      MEMORY: 2G
    volumes:
      - ./data:/data
      - ./manifest.json:/manifest.json:ro
    ports:
      - "25565:25565"

{
    "minecraft": {
        "version": "1.12.2",
        "modLoaders": [
            {
                "id": "forge-14.23.5.2860",
                "primary": true
            }
        ]
    },
    "manifestType": "minecraftModpack",
    "manifestVersion": 1,
    "name": "just biomes o plenty",
    "author": "",
    "files": [
        {
            "projectID": 220318,
            "fileID": 3558882,
            "required": true
        }
    ]
}


Container logs
If REMOVE_OLD_MODS: "true" then the mod is added to the mods folder, but then it is deleted before the server starts. I don't think this deletion is correct, as the mod isn't "old"; it doesn't make sense to add then immediately remove that same mod. Perhaps I'm misunderstanding something.
Specific process to prove / reproduce:
In one terminal, run a command to see the changes in the files in the directory, filtered by biomes o plenty.
# changes.log
watchmedo log --patterns="BiomesOPlenty-1.12.2-7.0.1.2445-universal.jar" --ignore-directories --recursive . > changes.log
Then in the other, start it up:
docker-compose up
Wait for the server to finish booting, then ctrl-c on the docker compose, then ctrl-c on the watchmedo.
changes.log looks like this (shows the creation and deletion):
on_created(self=<watchdog.tricks.LoggerTrick object at 0x7fcfed45b460>, event=<FileCreatedEvent: event_type=created, src_path='./data/mods/BiomesOPlenty-1.12.2-7.0.1.2445-universal.jar', is_directory=False>)
on_modified(self=<watchdog.tricks.LoggerTrick object at 0x7fcfed45b460>, event=<FileModifiedEvent: event_type=modified, src_path='./data/mods/BiomesOPlenty-1.12.2-7.0.1.2445-universal.jar', is_directory=False>)
...
on_deleted(self=<watchdog.tricks.LoggerTrick object at 0x7fcfed45b460>, event=<FileDeletedEvent: event_type=deleted, src_path='./data/mods/BiomesOPlenty-1.12.2-7.0.1.2445-universal.jar', is_directory=False>)

Closing comment (2024-01-08T13:04:03Z): Duplicate of #2530