{"record":{"id":"f54c6f9702a73134","repo":"Anuken/Mindustry","slug":"a-mod-with-the-name-basename-is-already-import","errorCode":null,"errorMessage":"A mod with the name '{baseName}' is already imported.","messagePattern":"A mod with the name '(.+?)' is already imported\\.","errorType":"validation","errorClass":"ModLoadException","httpStatus":null,"severity":"error","filePath":"core/src/mindustry/mod/Mods.java","lineNumber":1133,"sourceCode":"                        Fi cacheDir = new Fi(Core.files.getCachePath()).child(\"mods\");\n                        Fi modCacheDir = cacheDir.child(other.file.nameWithoutExtension());\n                        modCacheDir.deleteDirectory();\n                    }\n\n                    //close zip file\n                    if(other.root instanceof ZipFi){\n                        other.root.delete();\n                    }\n                    //delete the old mod directory\n                    if(other.file.isDirectory()){\n                        other.file.deleteDirectory();\n                    }else{\n                        other.file.delete();\n                    }\n                    //unload\n                    mods.remove(other);\n                }else{\n                    throw new ModLoadException(\"A mod with the name '\" + baseName + \"' is already imported.\");\n                }\n            }\n\n            ClassLoader loader = null;\n            Mod mainMod;\n            Fi mainFile = zip;\n\n            if(android){\n                mainFile = mainFile.child(\"classes.dex\");\n            }else{\n                String[] path = (mainClass.replace('.', '/') + \".class\").split(\"/\");\n                for(String str : path){\n                    if(!str.isEmpty()){\n                        mainFile = mainFile.child(str);\n                    }\n                }\n            }\n","sourceCodeStart":1115,"sourceCodeEnd":1151,"githubUrl":"https://github.com/Anuken/Mindustry/blob/f695ad7e60323ebced984fa26d0bcf0bc54296b4/core/src/mindustry/mod/Mods.java#L1115-L1151","documentation":"When importing a mod, if another mod with the same baseName already exists and cannot be overwritten (e.g. it has a Steam ID), loadMod throws ModLoadException. Non-Steam duplicates are silently overwritten; Steam ones must be removed via unsubscribe.","triggerScenarios":"Importing a local mod whose normalized name matches an already-imported Steam mod (hasSteamID() true).","commonSituations":"Re-importing a mod also installed from Steam; two mods sharing the same name field; development copy colliding with a subscribed Workshop item.","solutions":["Unsubscribe the existing Steam mod first, then import.","Rename your mod's 'name' field to a unique baseName.","Remove the duplicate from the mods directory."],"exampleFix":"// before: meta.json name \"example\" collides with subscribed Steam mod\n// after: change \"name\": \"example\" to \"name\": \"example-dev\"","handlingStrategy":"validation","validationCode":"// Check for an existing same-name mod before importing.\nString baseName = meta.name.toLowerCase(Locale.ROOT).replace(\" \", \"-\");\nLoadedMod existing = mods.getMods().find(m -> m.name.equals(baseName));\nif(existing != null && existing.hasSteamID()) {\n    throw new ModLoadException(\"Conflict with Steam mod '\" + baseName + \"'; unsubscribe first.\");\n}","typeGuard":"boolean nameIsFree(Mods mods, String name){\n    String base = name.toLowerCase(Locale.ROOT).replace(\" \", \"-\");\n    return mods.getMods().noneMatch(m -> m.name.equals(base));\n}","tryCatchPattern":"try {\n    mods.importMod(file);\n} catch(ModLoadException e) {\n    if(e.getMessage().contains(\"already imported\")) { /* unsubscribe Steam dup or rename */ }\n    else throw e;\n}","preventionTips":["Give mods unique 'name' values.","Unsubscribe conflicting Steam Workshop items before local imports.","Check installed mods before importing a dev copy."],"tags":["modding","packaging","duplicate","steam"],"backgroundTag":null,"analyzedSha":"f695ad7e60323ebced984fa26d0bcf0bc54296b4","analyzedAt":"2026-08-14T04:31:16.262Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}