{"record":{"id":"600fb52eae087042","repo":"abiosoft/colima","slug":"error-running-s-provision-script-s","errorCode":null,"errorMessage":"error running %s provision script(s)","messagePattern":"error running (.+?) provision script\\(s\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app/app.go","lineNumber":175,"sourceCode":"\n\tif err := generateSSHConfig(conf.SSHConfig); err != nil {\n\t\tlog.Trace(\"error generating ssh_config: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc (c colimaApp) runProvisionScripts(conf config.Config, mode string) {\n\tvar failed bool\n\tfor _, s := range conf.Provision {\n\t\tif s.Mode != mode {\n\t\t\tcontinue\n\t\t}\n\t\tif err := c.guest.Run(\"sh\", \"-c\", s.Script); err != nil {\n\t\t\tfailed = true\n\t\t}\n\t}\n\tif failed {\n\t\tlog.Warnln(fmt.Errorf(\"error running %s provision script(s)\", mode))\n\t}\n}\n\nfunc (c colimaApp) Stop(force bool) error {\n\tctx := context.Background()\n\tlog.Println(\"stopping\", config.CurrentProfile().DisplayName)\n\n\t// the order for stop is:\n\t//   container stop -> vm stop\n\n\t// stop container runtimes only if the guest is responsive\n\tif c.guest.Running(ctx) && c.guestResponsive() {\n\t\tcontainers, err := c.currentContainerEnvironments(ctx)\n\t\tif err != nil {\n\t\t\tlog.Warnln(fmt.Errorf(\"error retrieving runtimes: %w\", err))\n\t\t}\n\n\t\t// stop happens in reverse of start","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/app/app.go#L157-L193","documentation":"runProvisionScripts executes user-defined provision scripts (the config `provision` list) inside the guest via `sh -c` for a given mode (start/after-boot/ready); if any fail, this aggregated warning is printed once. Note a formatting defect: the mode argument is never passed to fmt.Errorf, so it renders as `error running %!s(MISSING) provision script(s)`. Non-fatal by design: start continues.","triggerScenarios":"A provision script from `colima start --provision` or config.yaml exits non-zero in the guest: bad syntax, commands missing from the appliance image, missing mounts, or a script assuming a runtime that is not up yet (wrong mode).","commonSituations":"Script written for docker runs in after-boot mode before docker exists; script references $HOME paths absent for the script user; copy-pasted YAML with broken quoting so `sh -c` receives garbage.","solutions":["Run the script manually to see the real error: `colima ssh -- sh -c '<script>'`","Check the mode: scripts needing docker/kubernetes must use a mode that runs after the runtime is up (e.g. ready), not start/after-boot","Validate the YAML quoting of the provision entry so the script string arrives intact","Test with `colima start --verbose` and watch guest output before enabling the script permanently"],"exampleFix":"# before (script fails: references docker before runtime is up)\nprovision:\n- mode: afterBoot\n  script: docker load -i /tmp/images.tar\n\n# after\nprovision:\n- mode: ready\n  script: docker load -i /tmp/images.tar","handlingStrategy":"validation","validationCode":"// dry-run each provision script for syntax before starting\nfor _, s := range conf.Provision {\n    if err := exec.Command(\"sh\", \"-n\", s.Script).Run(); err != nil {\n        return fmt.Errorf(\"provision script (mode %s) has a syntax error: %w\", s.Mode, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"// warnings are not surfaced as errors; after start, manually replay each script to confirm:\n// colima ssh -- sh -c '<script>'","preventionTips":["Test scripts manually with `colima ssh -- sh -c '...'` before registering them","Match script mode to dependencies (ready = runtimes up; afterBoot = VM only)","Quote YAML strings carefully so the script arrives intact"],"tags":["provisioning","scripts","yaml","vm"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}