Skip to content
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

module name conflict with .vmodules/cache and local module 'cache' #22459

Closed
bitmaxis opened this issue Oct 9, 2024 · 1 comment
Closed

module name conflict with .vmodules/cache and local module 'cache' #22459

bitmaxis opened this issue Oct 9, 2024 · 1 comment
Assignees
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.

Comments

@bitmaxis
Copy link

bitmaxis commented Oct 9, 2024

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.

@bitmaxis bitmaxis added the Bug This tag is applied to issues which reports bugs. label Oct 9, 2024
@bitmaxis
Copy link
Author

bitmaxis commented Oct 9, 2024

oops, 'slightly more opaqe, e.g. cache' should have read __cache__

@spytheman spytheman self-assigned this Oct 10, 2024
@spytheman spytheman added the Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. label Oct 10, 2024
spytheman added a commit to spytheman/v that referenced this issue Oct 10, 2024
…owing for user modules, that are named `cache` (fix vlang#22459)
spytheman added a commit to spytheman/v that referenced this issue Oct 10, 2024
…owing for user modules, that are named `cache` (fix vlang#22459)
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. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.
Projects
None yet
Development

No branches or pull requests

2 participants