Skip to content

Commit c2a3eef

Browse files
authored
tools: fix windows install of an already existing module with vpm (#19761)
1 parent 1a53a46 commit c2a3eef

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

cmd/tools/vpm/install.v

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,18 @@ fn vpm_install_from_vcs(modules []string, vcs &VCS) {
184184
if os.exists(minfo.final_module_path) {
185185
eprintln('Warning module "${minfo.final_module_path}" already exists!')
186186
eprintln('Removing module "${minfo.final_module_path}" ...')
187-
os.rmdir_all(minfo.final_module_path) or {
187+
mut err_msg := ''
188+
$if windows {
189+
os.execute_opt('rd /s /q ${minfo.final_module_path}') or {
190+
err_msg = err.msg()
191+
}
192+
} $else {
193+
os.rmdir_all(minfo.final_module_path) or { err_msg = err.msg() }
194+
}
195+
if err_msg != '' {
188196
errors++
189197
eprintln('Errors while removing "${minfo.final_module_path}" :')
190-
eprintln(err)
198+
eprintln(err_msg)
191199
continue
192200
}
193201
}

cmd/tools/vpm/install_test.v

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ fn test_install_from_git_url() {
5252
}
5353

5454
fn test_install_already_existent() {
55-
// FIXME: Skip this for now on Windows, as `rmdir_all` results in permission
56-
// errors when vpm tries to remove existing modules.
57-
$if windows {
58-
return
59-
}
6055
mut res := os.execute('${v} install https://github.com/vlang/markdown')
6156
assert res.exit_code == 0, res.output
6257
assert res.output.contains('already exists')

0 commit comments

Comments
 (0)