From 93d6c98df4501ecd7690f21c689f10de959e0f8b Mon Sep 17 00:00:00 2001 From: Julian Hofer Date: Thu, 12 Dec 2024 17:47:00 +0100 Subject: [PATCH] fix: config search order This fixes three problems: - the config order was wrong, global config was for some cases winning over local - move config file of tmp_pixi_workspace to correct folder - add a config reset for all tests so that our test run with a clean config --- crates/pixi_config/src/lib.rs | 18 +++++++++--------- tests/integration_python/conftest.py | 18 +++++++++++++++++- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/crates/pixi_config/src/lib.rs b/crates/pixi_config/src/lib.rs index f077049f41..b657dbc4a6 100644 --- a/crates/pixi_config/src/lib.rs +++ b/crates/pixi_config/src/lib.rs @@ -873,7 +873,7 @@ impl Config { .join(consts::CONFIG_FILE); match Self::from_path(&local_config_path) { - Ok(c) => config = config.merge_config(c), + Ok(local_config) => config = local_config.merge_config(config), Err(e) => tracing::debug!( "Failed to load local config: {} (error: {})", local_config_path.display(), @@ -910,9 +910,9 @@ impl Config { /// Merge the given config into the current one. #[must_use] - pub fn merge_config(mut self, other: Config) -> Self { - self.mirrors.extend(other.mirrors); - self.loaded_from.extend(other.loaded_from); + pub fn merge_config(self, mut other: Config) -> Self { + other.mirrors.extend(self.mirrors); + other.loaded_from.extend(self.loaded_from); Self { default_channels: if other.default_channels.is_empty() { @@ -925,16 +925,16 @@ impl Config { authentication_override_file: other .authentication_override_file .or(self.authentication_override_file), - mirrors: self.mirrors, - loaded_from: self.loaded_from, + mirrors: other.mirrors, + loaded_from: other.loaded_from, // currently this is always the default so just use the other value channel_config: other.channel_config, - repodata_config: other.repodata_config.merge(self.repodata_config), - pypi_config: other.pypi_config.merge(self.pypi_config), + repodata_config: self.repodata_config.merge(other.repodata_config), + pypi_config: self.pypi_config.merge(other.pypi_config), detached_environments: other.detached_environments.or(self.detached_environments), pinning_strategy: other.pinning_strategy.or(self.pinning_strategy), force_activate: other.force_activate, - experimental: other.experimental.merge(self.experimental), + experimental: self.experimental.merge(other.experimental), // Make other take precedence over self to allow for setting the value through the CLI concurrency: self.concurrency.merge(other.concurrency), } diff --git a/tests/integration_python/conftest.py b/tests/integration_python/conftest.py index 9b963831b4..d3988f05c0 100644 --- a/tests/integration_python/conftest.py +++ b/tests/integration_python/conftest.py @@ -21,10 +21,26 @@ def pixi(request: pytest.FixtureRequest) -> Path: @pytest.fixture def tmp_pixi_workspace(tmp_path: Path) -> Path: pixi_config = """ +# Reset to defaults +default-channels = ["conda-forge"] +change-ps1 = true +tls-no-verify = false +detached-environments = false +pinning-strategy = "semver" + +[concurrency] +downloads = 50 + +[experimental] +use-environment-activation-cache = false + +# Enable sharded repodata [repodata-config."https://prefix.dev/"] disable-sharded = false """ - tmp_path.joinpath("config.toml").write_text(pixi_config) + dot_pixi = tmp_path.joinpath(".pixi") + dot_pixi.mkdir() + dot_pixi.joinpath("config.toml").write_text(pixi_config) return tmp_path