Skip to content

Commit

Permalink
fix: config search order
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Hofer-Julian committed Dec 12, 2024
1 parent b6d8407 commit 93d6c98
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
18 changes: 9 additions & 9 deletions crates/pixi_config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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() {
Expand All @@ -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),
}
Expand Down
18 changes: 17 additions & 1 deletion tests/integration_python/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 93d6c98

Please sign in to comment.