{"record":{"id":"052ac11997f9caf4","repo":"3b1b/manim","slug":"please-use-a-valid-color","errorCode":null,"errorMessage":"Please use a valid color","messagePattern":"Please use a valid color","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"manimlib/config.py","lineNumber":261,"sourceCode":"    window_config = config.window\n    for key in \"position\", \"size\":\n        if window_config.get(key):\n            window_config[key] = literal_eval(window_config[key])\n    if args.full_screen:\n        window_config.full_screen = True\n\n\ndef update_camera_config(config: Dict, args: Namespace):\n    camera_config = config.camera\n    arg_resolution = get_resolution_from_args(args, config.resolution_options)\n    camera_config.resolution = arg_resolution or literal_eval(camera_config.resolution)\n    if args.fps:\n        camera_config.fps = args.fps\n    if args.color:\n        try:\n            camera_config.background_color = colour.Color(args.color)\n        except Exception as err:\n            log.error(\"Please use a valid color\")\n            log.error(err)\n            sys.exit(2)\n    if args.transparent:\n        camera_config.background_opacity = 0.0\n\n\ndef update_file_writer_config(config: Dict, args: Namespace):\n    file_writer_config = config.file_writer\n    file_writer_config.update(\n        write_to_movie=(not args.skip_animations and args.write_file),\n        subdivide_output=args.subdivide,\n        save_last_frame=(args.skip_animations and args.write_file),\n        png_mode=(\"RGBA\" if args.transparent else \"RGB\"),\n        movie_file_extension=(get_file_ext(args)),\n        output_directory=get_output_directory(args, config),\n        file_name=args.file_name,\n        open_file_upon_completion=args.open,\n        show_file_location_upon_completion=args.finder,","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/3b1b/manim/blob/dee01804d47b9f94402d71472674710dcac125b8/manimlib/config.py#L243-L279","documentation":"While applying CLI/config arguments, update_camera_config parses the -c/--color background color with colour.Color. If parsing fails, manim logs 'Please use a valid color' plus the underlying colour-library error and exits with status 2 — it is a startup-time config failure, not a Python exception propagated to the caller.","triggerScenarios":"Running manim -c 'darkblue2x' file.py Scene, or any color string colour.Color cannot parse: bad hex like '#GGGGGG', named colors that don't exist in the colour module, strings with stray whitespace or quotes.","commonSituations":"Using web CSS color names (e.g. 'slategray') that the colour library doesn't define; typos in hex codes; assuming RGB tuples or 0xRRGGBB integers work as strings; scripts that pass a programmatically-built color string.","solutions":["Use a 6-digit hex string: -c '#1a2b3c' or '#1A2B3C'","Use a color name the colour library knows: -c DARK_BLUE, -c red, -c teal","Note the CLI takes a string; if setting from Python, assign colour.Color(...) or manim's ManimColor-compatible values, not a tuple"],"exampleFix":"# before\nmanim -c slate_grey_bluish scene.py MyScene\n# after\nmanim -c '#3C4043' scene.py MyScene","handlingStrategy":"validation","validationCode":"import colour\ncolor = \"#3C4043\"\ntry:\n    colour.Color(color)\nexcept ValueError:\n    raise SystemExit(f\"{color!r} is not a colour-library color; use hex like '#RRGGBB'\")","typeGuard":"import colour\ndef is_valid_color(s: str) -> bool:\n    try:\n        colour.Color(s)\n        return True\n    except Exception:\n        return False","tryCatchPattern":null,"preventionTips":["Prefer hex strings '#RRGGBB' — they always parse","Validate color strings in your build scripts before invoking manim, so exit code 2 never surprises CI"],"tags":["config","cli","color","startup"],"backgroundTag":null,"analyzedSha":"dee01804d47b9f94402d71472674710dcac125b8","analyzedAt":"2026-08-14T19:53:44.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}