Skip to content

CLI validates commands before checking -cc flag validity, resulting in "unknown command ''" #27868

Description

@arshalaromal

Describe the bug

When passing an invalid C compiler via the -cc flag, the CLI evaluates the command/file arguments before validating if the requested C compiler actually exists. This leads to confusing error messages where the CLI complains about missing or invalid commands instead of the missing C compiler.

Reproduction Steps

No command provided

$ v -cc foo

Invalid command provided

$ v -cc foo bar

Valid command provided (only now does it check -cc)

$ v -cc foo -e 

Expected Behavior

When running v -cc foo, the compiler should validate the -cc argument early and immediately output:

builder error: C compiler 'foo' was requested with '-cc', but was not found.

Current Behavior

1. No command provided

$ v -cc foo
v: unknown command ``
Run  v help  for usage.

2. Invalid command provided

$ v -cc foo bar
v: unknown command `bar`.
Did you mean `share`?
Run  v help  for usage.

3. Valid command provided (only now does it check -cc)

$ v -cc foo -e
builder error: C compiler `foo` was requested with `-cc`, but was not found

Possible Solution

The validation for the -cc flag should be moved earlier in the execution pipeline, likely during the initial flag parsing. By checking if the requested C compiler exists immediately after the flag is consumed, the CLI can throw the correct builder error before the command router ever attempts to evaluate the remaining (or empty) arguments.

Additional Information/Context

No response

V version

V 0.5.2

Environment details (OS name and version, etc.)

V full version V 0.5.2 3ca26c8.c5beb49
OS windows, Microsoft Windows 10 Home Single Language 19045 64-bit
Processor 4 cpus, 64bit, little endian, Intel(R) Core(TM) i5-4210M CPU @ 2.60GHz
Memory 2.64GB/7.93GB
V executable D:\v\v.exe
V last modified time 2026-07-19 05:15:20
V home dir OK, value: D:\v
VMODULES OK, value: C:\Users\USERNAME.vmodules
VTMP OK, value: C:\Users\USERNAME\AppData\Local\Temp\v_0
Current working dir OK, value: D:\v
Git version git version 2.45.1.windows.1
V git status 0.5.2-52-gc1ad7716
.git/config present true
cc version N/A
gcc version N/A
clang version N/A
msvc version N/A
tcc version tcc version 0.9.27 (x86_64 Windows)
tcc git status thirdparty-windows-amd64 b9cfff43
emcc version N/A
glibc version N/A

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions