From c04791fc41be46ba3752a2017fe57fdfbcbda66b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8D=8E=E4=BA=AE?= Date: Sat, 3 Feb 2018 20:21:49 +0800 Subject: [PATCH 1/2] fix issue :https://github.com/Masterminds/glide/issues/960. --- path/winbug.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/path/winbug.go b/path/winbug.go index ddb423b4..e95ba5a6 100644 --- a/path/winbug.go +++ b/path/winbug.go @@ -72,10 +72,19 @@ func CustomRename(o, n string) error { // Handking windows cases first if runtime.GOOS == "windows" { msg.Debug("Detected Windows. Moving files using windows command") - cmd := exec.Command("cmd.exe", "/c", "move", o, n) + + // fix issue: https://github.com/Masterminds/glide/issues/960. + // using XCOPY and RMDIR two commands to replace MOVE + cmd := exec.Command("cmd.exe", "/Y /T /E /I", "XCOPY", o, n) output, err := cmd.CombinedOutput() if err != nil { - return fmt.Errorf("Error moving files: %s. output: %s", err, output) + return fmt.Errorf("Error copying files: %s. output: %s", err, output) + } + + cmd = exec.Command("cmd.exe", "/S /Q","RMDIR", o) + output, err = cmd.CombinedOutput() + if err != nil { + return fmt.Errorf("Error removing files: %s. output: %s", err, output) } return nil From f0b13d9c403f82c50f8dd17b84340a6a54b38827 Mon Sep 17 00:00:00 2001 From: nilyang Date: Sun, 4 Feb 2018 11:31:44 +0800 Subject: [PATCH 2/2] fixes #960 : "Unable to export dependencies to vendor directory: Error moving files: exit status 1" --- path/winbug.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/path/winbug.go b/path/winbug.go index e95ba5a6..8ad7ec58 100644 --- a/path/winbug.go +++ b/path/winbug.go @@ -74,17 +74,21 @@ func CustomRename(o, n string) error { msg.Debug("Detected Windows. Moving files using windows command") // fix issue: https://github.com/Masterminds/glide/issues/960. - // using XCOPY and RMDIR two commands to replace MOVE - cmd := exec.Command("cmd.exe", "/Y /T /E /I", "XCOPY", o, n) + // "Unable to export dependencies to vendor directory: Error moving files: exit status 1" + // using XCOPY and RMDIR to replace MOVE + cmd := exec.Command("cmd.exe", "/C","XCOPY", "/Y", "/E", "/I", "/Q", o, n) output, err := cmd.CombinedOutput() if err != nil { return fmt.Errorf("Error copying files: %s. output: %s", err, output) } - cmd = exec.Command("cmd.exe", "/S /Q","RMDIR", o) + cmd = exec.Command("cmd.exe", "/C", "RMDIR", "/S", "/Q", o) output, err = cmd.CombinedOutput() if err != nil { - return fmt.Errorf("Error removing files: %s. output: %s", err, output) + exitCode := getExitCode(err) + if exitCode != winErrorFileNotFound && exitCode != winErrorPathNotFound { + return fmt.Errorf("Error removing files: %s. output: %s", err, output) + } } return nil