module name conflict with .vmodules/cache and local module 'cache' #22459
Labels
Bug
This tag is applied to issues which reports bugs.
Unit: Compiler
Bugs/feature requests, that are related to the V compiler in general.
Describe the bug
module naming conflict between local cache module and ~/.vmodules/cache
Reproduction Steps
create a cache module in your project, I am using a local xiusin.cache renamed to simply src/cache
Expected Behavior
i expected a clean compilation
Current Behavior
I have a local module defined in src/cache.
If i try to compile with default setting i get
v .
src/main.v:6:1: builder error: cannot import module "cache" (no .v files in "/home/ritchie/.vmodules/cache")
4 | import os
5 | import x.json2
6 | import cache
| ~~~~~~~~~~~~
7 |
8 | // type Any = json2.Any
after
rm -rf ~/.vmodules/cache
set -x VCACHE ~/.vmodules/kache
v .
I get a clean compile.
Specifically this effects xiusin.cache on vpm and crashes v-analyser in vscode.
Possible Solution
Suggestion is to make ~/.vmodules/cache defined in vcache.v somewhat more opaque,e.g. cache
pub fn new_cache_manager(opts []string) CacheManager {
mut vcache_basepath := os.getenv('VCACHE')
if vcache_basepath == '' {
vcache_basepath = os.join_path(os.vmodules_dir(), 'cache')
}
Additional Information/Context
No response
V version
e1480b6
Environment details (OS name and version, etc.)
ubuntu noble
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.
The text was updated successfully, but these errors were encountered: