diff --git a/libmamba/src/core/util_os.cpp b/libmamba/src/core/util_os.cpp index ccea2658fb..0c361534c5 100644 --- a/libmamba/src/core/util_os.cpp +++ b/libmamba/src/core/util_os.cpp @@ -139,19 +139,25 @@ namespace mamba { // Needs to be set system-wide & can only be run as admin ... - auto win_ver = util::windows_version(); + const auto win_ver = util::windows_version(); + LOG_DEBUG << fmt::format("Windows version : {}", win_ver ? win_ver.value() : win_ver.error().message); + + static constexpr auto error_message_wrong_version = "Not setting long path registry key;" + "Windows version must be at least 10 with the fall 2016 \"Anniversary update\" or newer."; + if (!win_ver.has_value()) { - LOG_WARNING << "Not setting long path registry key; Windows version must be at least 10 " - "with the fall 2016 \"Anniversary update\" or newer."; + LOG_WARNING << "failed to acquire Windows version - " << error_message_wrong_version; return false; } + + auto split_out = util::split(win_ver.value(), "."); if (!(split_out.size() >= 3 && std::stoull(split_out[0]) >= 10 && std::stoull(split_out[2]) >= 14352)) { - LOG_WARNING << "Not setting long path registry key; Windows version must be at least 10 " - "with the fall 2016 \"Anniversary update\" or newer."; + LOG_WARNING << "Windows version found:" << win_ver.value() << " - " + << error_message_wrong_version; return false; } @@ -164,7 +170,8 @@ namespace mamba } catch (const winreg::RegException& /*e*/) { - LOG_INFO << "No LongPathsEnabled key detected."; + LOG_INFO << "No LongPathsEnabled key detected. (Windows version = " << win_ver.value() + << ")"; return false; } @@ -173,8 +180,9 @@ namespace mamba auto out = Console::stream(); fmt::print( out, - "{}", - fmt::styled("Windows long-path support already enabled.", palette.ignored) + "{} (Windows version = {})", + fmt::styled("Windows long-path support already enabled.", palette.ignored), + win_ver.value() ); return true; } diff --git a/libmamba/src/util/os_win.cpp b/libmamba/src/util/os_win.cpp index 2d10fdb06e..5ab0f74597 100644 --- a/libmamba/src/util/os_win.cpp +++ b/libmamba/src/util/os_win.cpp @@ -218,7 +218,11 @@ namespace mamba::util // from python static const auto ver_output_regex = std::regex(R"((?:([\w ]+) ([\w.]+) .*\[.* ([\d.]+)\]))"); - if (auto rmatch = std::smatch(); std::regex_match(out, rmatch, ver_output_regex)) + // The output of the command could contain multiple unrelated lines, so we need to check + // every lines, which is why we need to search in a loop until reaching the end of the output. + std::smatch rmatch; + auto start_it = out.cbegin(); + while (std::regex_search(start_it, out.cend(), rmatch, ver_output_regex)) { std::string full_version = rmatch[3]; auto version_elems = util::split(full_version, ".");