From 0bbbf1e8019f232fa5e8dbaad5ed675afdb5f439 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 6 Jun 2023 18:01:58 +0300 Subject: [PATCH] v.util: make util.launch_tool/3 more robust, by recompiling V tools always in a known current working folder (vroot) (#18358) --- vlib/v/util/util.v | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vlib/v/util/util.v b/vlib/v/util/util.v index 89e9acd000..3bb8c7268f 100644 --- a/vlib/v/util/util.v +++ b/vlib/v/util/util.v @@ -180,9 +180,13 @@ pub fn launch_tool(is_verbose bool, tool_name string, args []string) { println('Compiling ${tool_name} with: "${compilation_command}"') } + current_work_dir := os.getwd() retry_max_count := 3 for i in 0 .. retry_max_count { + // ensure a stable and known working folder, when compiling V's tools, to avoid module lookup problems: + os.chdir(vroot) or {} tool_compilation := os.execute(compilation_command) + os.chdir(current_work_dir) or {} if tool_compilation.exit_code == 0 { break } else {