{"record":{"id":"70540c1c0f6b43bf","repo":"python/cpython","slug":"usage-seticon-icon-target","errorCode":null,"errorMessage":"Usage: seticon ICON TARGET","messagePattern":"Usage: seticon ICON TARGET","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"Mac/BuildScript/seticon.m","lineNumber":10,"sourceCode":"/*\n * Simple tool for setting an icon on a file.\n */\n#import <Cocoa/Cocoa.h>\n#include <stdio.h>\n\nint main(int argc, char** argv)\n{\n\tif (argc != 3) {\n\t\tfprintf(stderr, \"Usage: seticon ICON TARGET\");\n\t\treturn 1;\n\t}\n\n\tNSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];\n\tNSString* iconPath = [NSString stringWithUTF8String:argv[1]];\n\tNSString* filePath = [NSString stringWithUTF8String:argv[2]];\n\n\t[NSApplication sharedApplication];\n\n\t[[NSWorkspace sharedWorkspace]\n\t\tsetIcon: [[NSImage alloc] initWithContentsOfFile: iconPath]\n\t\tforFile: filePath\n\t\toptions: 0];\n\t[pool release];\n\treturn 0;\n}\n","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/python/cpython/blob/bc6749cc3b5ae4a5e88a6cc2d5b3bebbe354eae6/Mac/BuildScript/seticon.m#L1-L27","documentation":"Usage message from the macOS build helper seticon (Mac/BuildScript/seticon.m), a small Cocoa tool that stamps an icon onto a file. It prints 'Usage: seticon ICON TARGET' to stderr and exits 1 when argc != 3 — i.e. the program was not given exactly one icon path and one target path.","triggerScenarios":"Running ./seticon with 0, 1, or 3+ arguments; invoking it from a build script where one of the two expected paths expanded to empty or the paths were quoted as a single argument.","commonSituations":"Broken build scripts after relocating resources; Makefile recipes passing unquoted variables containing spaces; invoking the tool with flags it does not support (it takes none).","solutions":["Invoke with exactly two arguments: ./seticon path/to/icon.icns path/to/target","Quote both paths in shell recipes: \"$(RESOURCES_DIR)/icon.icns\" \"$(APP_TARGET)\"","Verify both paths exist before calling (the tool itself will proceed to NSImage init otherwise)"],"exampleFix":"# before\n./seticon $ICON $TARGET extra\n# after\n./seticon \"$ICON\" \"$TARGET\"","handlingStrategy":"validation","validationCode":"# bash: check arity and inputs before calling the tool\n[ $# -eq 2 ] && [ -f \"$1\" ] && [ -e \"$2\" ] || { echo \"Usage: seticon ICON TARGET\" >&2; exit 1; }\n./seticon \"$1\" \"$2\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quote both icon and target paths in Makefile recipes","Verify resource paths exist during the build before invoking seticon","Remember the tool accepts exactly two positional arguments and no options"],"tags":["macos","build-tooling","cli","usage","cocoa"],"backgroundTag":null,"analyzedSha":"bc6749cc3b5ae4a5e88a6cc2d5b3bebbe354eae6","analyzedAt":"2026-08-14T22:01:13.976Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}