lima-vm/lima · error
the file argument can be specified only for --check mode
Error message
the file argument can be specified only for --check mode
What it means
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.
Source
Thrown at cmd/limactl/sudoers_darwin.go:40
return err
}
// Make sure the current network configuration is secure
if err := nwCfg.Validate(); err != nil {
logrus.Infof("Please check %s for more information.", socketVMNetURL)
return err
}
check, err := cmd.Flags().GetBool("check")
if err != nil {
return err
}
if check {
return verifySudoAccess(ctx, nwCfg, args, cmd.OutOrStdout())
}
switch len(args) {
case 0:
// NOP
case 1:
return errors.New("the file argument can be specified only for --check mode")
default:
return fmt.Errorf("unexpected arguments %v", args)
}
sudoers, err := networks.Sudoers()
if err != nil {
return err
}
fmt.Fprint(cmd.OutOrStdout(), sudoers)
return nil
}
func verifySudoAccess(ctx context.Context, nwCfg networks.Config, args []string, stdout io.Writer) error {
var file string
switch len(args) {
case 0:
file = nwCfg.Paths.Sudoers
if file == "" {
cfgFile, _ := networks.ConfigFile()View on GitHub (pinned to dd909d0973)
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
Example fix
// before limactl sudoers /etc/sudoers.d/lima // after sudo limactl sudoers > /etc/sudoers.d/lima # or, to verify: limactl sudoers --check /etc/sudoers.d/lima
Defensive patterns
Strategy: validation
Validate before calling
[[ $# -eq 0 || $1 == --check ]] || { echo 'file argument requires --check'; exit 2; } Try / catch
if ! out=$(limactl sudoers 2>&1); then echo "$out"; fi
Prevention
- Remember: no-arg prints, --check verifies, --output installs
- Only pass a file together with --check
- Check `limactl sudoers --help` for the current flag set
When it happens
Trigger: `limactl sudoers /etc/sudoers.d/lima` (a single file argument) without the --check flag.
Common situations: Users copying older docs or Linux instructions that took a file path; confusing `limactl sudoers <file>` install usage with the --check verification usage.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- unexpected arguments %v
- can check only a single sudoers file
- no sudoers file defined in %#q
- sudoers command is only supported on macOS right now
- limactl is running under rosetta, please reinstall lima with
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/d26c46a4bacc8f45.
Report an issue: GitHub.