vlang / v

Simple, fast, safe, compiled language for developing maintainable software. Compiles itself in <1s with zero library dependencies. Supports automatic C => V translation. https://vlang.io
MIT License
35.64k stars 2.15k forks source link

[BUG]: V tool shows wrong case (`example-module` instead of `example_module`) while displaying errors on `v install example_module` #11145

Open gamemaker1 opened 3 years ago

gamemaker1 commented 3 years ago

V version: V 0.2.2 012b3f0 OS: Linux; Arch Linux; 64 bit

What did you do? Ran v install http_negotiator (that module didn't exist when I ran the command)

What did you expect to see?

Snake case while printing module name:

Errors while retrieving meta data for module http_negotiator:
Skipping module "http_negotiator", since https://vpm.vlang.io reported that "http_negotiator" does not exist.

What did you see instead?

Kebab case instead:

Errors while retrieving meta data for module http-negotiator:
Skipping module "http-negotiator", since https://vpm.vlang.io reported that "http-negotiator" does not exist.
gamemaker1 commented 3 years ago

Taking a crack at this issue, will link a PR for it shortly!

JalonSolov commented 3 years ago

I thought you actually tried importing http-negotiator, in which case what you expected to see was an error message telling you that was an invalid module name.

The fact that it told you the module doesn't exist when you tried importing http_negotiator was perfectly valid, since it didn't exist.

gamemaker1 commented 3 years ago

The fact that it told you the module doesn't exist when you tried importing http_negotiator was perfectly valid, since it didn't exist.

I agree. It is valid since it does not exist, but it is confusing that it 'renames' the module you are searching for when it says it cannot find the module.

Also, I do not see any reason why any underscores in the module name should be converted to dashes, especially since dashes are pretty much invalid in V.

Please let me know if there's something I've missed.

Thanks!

JalonSolov commented 3 years ago

It's only a problem if github (or whatever repo system houses the module) doesn't allow underscores.

gamemaker1 commented 3 years ago

I don't think even that is a problem - the final download happens using git clone --depth=1 $mod.url OR hg clone $mod.url:

// -- From /cmd/tools/vpm.v

vcs_install_cmd := supported_vcs_install_cmds[vcs]
cmd := '$vcs_install_cmd "$mod.url" "$final_module_path"'
cmdres := os.execute(cmd)

The V tool does not even attempt to generate a URL based on mod name and author name, it simply uses the URL provided by the author when they create the module in VPM.

Let me know if I'm overlooking something that uses/benefits from this (replace underscores with dashes) behaviour.

Thanks