From 069c32c97ab50fc626fd84bdd55b3f333d61ecd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Lamotte=20=28Klaim=29?= Date: Fri, 15 Nov 2024 16:23:12 +0100 Subject: [PATCH] prevent pip "rich" output --- libmamba/src/core/prefix_data.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libmamba/src/core/prefix_data.cpp b/libmamba/src/core/prefix_data.cpp index 00d8c4dab5..d8bbebfce1 100644 --- a/libmamba/src/core/prefix_data.cpp +++ b/libmamba/src/core/prefix_data.cpp @@ -215,13 +215,19 @@ namespace mamba const auto get_python_path = [&] { return util::which_in("python", util::get_path_dirs(m_prefix_path)).string(); }; - const auto args = std::array{ get_python_path(), + const auto args = std::array{ get_python_path(), + "-q", "-m", "pip", "inspect", "--local" }; - const std::vector> env{ { "PYTHONIOENCODING", "utf-8" } }; + const std::vector> env{ + { "PYTHONIOENCODING", "utf-8" }, + { "NO_COLOR", "1" }, + { "PIP_NO_COLOR", "1" }, + { "PIP_NO_PYTHON_VERSION_WARNING", "1" }, + }; reproc::options run_options; run_options.env.extra = reproc::env{ env }; @@ -261,11 +267,11 @@ namespace mamba { j = nlohmann::json::parse(out); } - catch (const std::exception& ec) + catch (const std::exception& parse_error) { const auto message = fmt::format( "failed to parse python command output:\n error: {}\n command ran: {}\n env options:{}\n-> output:\n{}\n\n-> error output:{}", - ec.what(), + parse_error.what(), fmt::join(args, " "), fmt::join(env, " "), out,