{"record":{"id":"d26c46a4bacc8f45","repo":"lima-vm/lima","slug":"the-file-argument-can-be-specified-only-for-chec","errorCode":null,"errorMessage":"the file argument can be specified only for --check mode","messagePattern":"the file argument can be specified only for --check mode","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/sudoers_darwin.go","lineNumber":40,"sourceCode":"\t\treturn err\n\t}\n\t// Make sure the current network configuration is secure\n\tif err := nwCfg.Validate(); err != nil {\n\t\tlogrus.Infof(\"Please check %s for more information.\", socketVMNetURL)\n\t\treturn err\n\t}\n\tcheck, err := cmd.Flags().GetBool(\"check\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif check {\n\t\treturn verifySudoAccess(ctx, nwCfg, args, cmd.OutOrStdout())\n\t}\n\tswitch len(args) {\n\tcase 0:\n\t\t// NOP\n\tcase 1:\n\t\treturn errors.New(\"the file argument can be specified only for --check mode\")\n\tdefault:\n\t\treturn fmt.Errorf(\"unexpected arguments %v\", args)\n\t}\n\tsudoers, err := networks.Sudoers()\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Fprint(cmd.OutOrStdout(), sudoers)\n\treturn nil\n}\n\nfunc verifySudoAccess(ctx context.Context, nwCfg networks.Config, args []string, stdout io.Writer) error {\n\tvar file string\n\tswitch len(args) {\n\tcase 0:\n\t\tfile = nwCfg.Paths.Sudoers\n\t\tif file == \"\" {\n\t\t\tcfgFile, _ := networks.ConfigFile()","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/sudoers_darwin.go#L22-L58","documentation":"On macOS, `limactl sudoers` without --check expects zero positional arguments: it prints the sudoers content to stdout. Passing exactly one argument (a file path) outside --check mode is rejected because writing/checking a specific file only makes sense in verification mode.","triggerScenarios":"`limactl sudoers /etc/sudoers.d/lima` (a single file argument) without the --check flag.","commonSituations":"Users copying older docs or Linux instructions that took a file path; confusing `limactl sudoers <file>` install usage with the --check verification usage.","solutions":["Add --check to verify an existing file: `limactl sudoers --check /etc/sudoers.d/lima`","Drop the argument to print the sudoers rules: `limactl sudoers > /etc/sudoers.d/lima`","Use more than one argument never; that raises the separate 'unexpected arguments' error"],"exampleFix":"// before\nlimactl sudoers /etc/sudoers.d/lima\n// after\nsudo limactl sudoers > /etc/sudoers.d/lima\n# or, to verify:\nlimactl sudoers --check /etc/sudoers.d/lima","handlingStrategy":"validation","validationCode":"[[ $# -eq 0 || $1 == --check ]] || { echo 'file argument requires --check'; exit 2; }","typeGuard":null,"tryCatchPattern":"if ! out=$(limactl sudoers 2>&1); then echo \"$out\"; fi","preventionTips":["Remember: no-arg prints, --check verifies, --output installs","Only pass a file together with --check","Check `limactl sudoers --help` for the current flag set"],"tags":["cli","macos","sudoers","argument-validation"],"backgroundTag":"invalid-cli-argument","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}