Skip to content

watch flag breaks backend option #24571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
alexbezhan opened this issue May 25, 2025 · 6 comments
Open

watch flag breaks backend option #24571

alexbezhan opened this issue May 25, 2025 · 6 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@alexbezhan
Copy link

alexbezhan commented May 25, 2025

Describe the bug

Without watch flag, compilation to js backend works.
With watch flag, it gives an error:
Unknown argument -baend``

Reproduction Steps

Given this single-file program:

fn main() {
    println('Hello world')
}

Compile it with:
v watch -backend js_browser file.v

Expected Behavior

Program is compiled and watch starts.

Current Behavior

Error: Unknown argument -baend``

Possible Solution

So there is some args parsing issue when using watch option.

Additional Information/Context

When omitting the watch option, the above command starts working correctly.

Also, replacing -backend with -b in the above command makes the compilation work.
But -b doesn't set the correct backend (probably another bug). It works correctly for -b js, but when used with -b js_browser it sets backend to js(not js_browser).

V version

0.4.10 22c327f

Environment details (OS name and version, etc.)

Mac OS Sonoma 14.3.1

@alexbezhan alexbezhan added the Bug This tag is applied to issues which reports bugs. label May 25, 2025
Copy link

Connected to Huly®: V_0.6-22936

@gchumillas
Copy link
Contributor

According to the documentation, all options should be placed in the beginning:

$ v help
V is a tool for managing V source code.

Usage:
  v [options] [command] [arguments]

This works:

v -backend js_browser watch file.v

@alexbezhan
Copy link
Author

According to the documentation, all options should be placed in the beginning:

$ v help
V is a tool for managing V source code.

Usage:
v [options] [command] [arguments]
This works:

v -backend js_browser watch file.v

Works, thanks. Closing the issue.

@alexbezhan alexbezhan closed this as not planned Won't fix, can't repro, duplicate, stale May 25, 2025
@JalonSolov JalonSolov reopened this May 25, 2025
@JalonSolov
Copy link
Contributor

It should stay open until we have a better error message.

The problem is that watch needs a parameter to tell it what to watch. It is taking the -backend option as that parameter.

The 2nd problem is that it is also doing something weird with that parameter, since it prints it back out with the ck missing from -backend. Then it reports that as an unknown option.

Very strange...

@gchumillas
Copy link
Contributor

gchumillas commented May 25, 2025

It's confusing, but it's not really a bug. Simply execute the following command:

$ v watch -help
v watch 0.0.2
-----------------------------------------------
Usage: v watch [options] [--silent] [--clear] [--ignore .db] [--add /path/to/a/file.v] [run] program.v

Description: Collect all .v files needed for a compilation, then re-run the compilation when any of the source changes.

Options:
  --vwatchworker            Internal flag. Used to distinguish vwatch manager and worker processes.
  -s, --silent              Be more silent; do not print the watch timestamp before each re-run.
  -c, --clear               Clears the terminal before each re-run.
  -k, --keep                Keep the program running. Restart it automatically, if it exits by itself. Useful for gg/ui apps.
  -a, --add <string>        Add more files to be watched. Useful with `v watch --add=/tmp/feature.v run cmd/v /tmp/feature.v`, if you change *both* the compiler, and the feature.v file.
  -i, --ignore <string>     Ignore files having these extensions. Useful with `v watch --ignore=.db run server.v`, if your server writes to an sqlite.db file in the same folder.
  -o, --only-watch <string>
                            Watch only files matching these globe patterns. Example for a markdown renderer project: `v watch --only-watch=*.v,*.md run .`
  -h, --help                Show this help screen.
  --before <string>         A command to execute *before* each re-run.
  --after <string>          A command to execute *after* each re-run.

The watch utility recognizes the options c and k, but not the rest of the letters (baend) :P

This is the correct usage:

v [v-options] watch [watch-options] file.v

For example:

v -backend js_browser watch -ck file.v

@JalonSolov
Copy link
Contributor

It is a bug, in that it the message given didn't make any sense. Useless error messages are almost worse than none at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

3 participants