{"record":{"id":"ef31f177681b5604","repo":"docker/compose","slug":"service-s-is-required-by-s-but-is-disabled-can","errorCode":null,"errorMessage":"service %s is required by %s but is disabled. Can be enabled by profiles %s","messagePattern":"service (.+?) is required by (.+?) but is disabled\\. Can be enabled by profiles (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compose/dependencies.go","lineNumber":273,"sourceCode":"\t}\n\n\tfor _, s := range project.Services {\n\t\tgraph.AddVertex(s.Name, s.Name, initialStatus)\n\t}\n\n\tfor index, s := range project.Services {\n\t\tfor _, name := range s.GetDependencies() {\n\t\t\terr := graph.AddEdge(s.Name, name)\n\t\t\tif err != nil {\n\t\t\t\tif !s.DependsOn[name].Required {\n\t\t\t\t\tdelete(s.DependsOn, name)\n\t\t\t\t\tproject.Services[index] = s\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif api.IsNotFoundError(err) {\n\t\t\t\t\tds, err := project.GetDisabledService(name)\n\t\t\t\t\tif err == nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"service %s is required by %s but is disabled. Can be enabled by profiles %s\", name, s.Name, ds.Profiles)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t}\n\n\tif b, err := graph.HasCycles(); b {\n\t\treturn nil, err\n\t}\n\n\treturn graph, nil\n}\n\n// NewVertex is the constructor function for the Vertex\nfunc NewVertex(key string, service string, initialStatus ServiceStatus) *Vertex {\n\treturn &Vertex{\n\t\tKey:      key,","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/compose/dependencies.go#L255-L291","documentation":"The dependency graph found a 'depends_on' edge to a service that exists in the project but is inactive because no enabling profile is set. Since depends_on defaults to required: true, compose reports which profiles would enable the missing service instead of failing with a plain not-found.","triggerScenarios":"services: {api: {depends_on: [db]}}, db has 'profiles: [debug]' but COMPOSE_PROFILES/--profile does not include debug; occurs while building the dependency graph during up/run.","commonSituations":"Optional services gated behind profiles (debug db, mailhog) referenced by always-on services; forgetting to export COMPOSE_PROFILES in CI; profile renamed but depends_on not updated.","solutions":["Enable the profile: COMPOSE_PROFILES=debug docker compose up or docker compose --profile debug up","If the dependency is truly optional, mark it: depends_on: {db: {required: false, condition: service_started}}","Move the service out of profiles if it is always required"],"exampleFix":"# before\nservices:\n  db:\n    profiles: [debug]\n  api:\n    depends_on: [db]\n# after (optional dep)\nservices:\n  api:\n    depends_on:\n      db:\n        condition: service_started\n        required: false","handlingStrategy":"validation","validationCode":"// before up: ensure every required dependency is active\ndisabled, _ := project.GetDisabledService(depName)\nif disabled.Name != \"\" {\n    return fmt.Errorf(\"enable profile(s) %v for %s or mark it optional\", disabled.Profiles, depName)\n}","typeGuard":null,"tryCatchPattern":"if err := compose.Up(...); err != nil && strings.Contains(err.Error(), \"is disabled. Can be enabled by profiles\") {\n    // add the suggested profile and retry\n    os.Setenv(\"COMPOSE_PROFILES\", strings.Join(append(profiles, \"debug\"), \",\"))\n    err = compose.Up(...)\n}","preventionTips":["Export COMPOSE_PROFILES in CI where profile-gated deps are used","Mark optional dependencies required: false","Document profile requirements in the repo README"],"tags":["dependencies","profiles","compose-file"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}