Skip to content

fix: Remove spurious emulation warning when just locking#5723

Merged
wolfv merged 2 commits intoprefix-dev:mainfrom
kilian-hu:fix/remove-spurious-emulation-warning
Mar 26, 2026
Merged

fix: Remove spurious emulation warning when just locking#5723
wolfv merged 2 commits intoprefix-dev:mainfrom
kilian-hu:fix/remove-spurious-emulation-warning

Conversation

@kilian-hu
Copy link
Copy Markdown
Contributor

Description

This PR fixes a bug that causes a spurious warning like this:

WARN osx-arm64 (Apple Silicon) is not supported by the pixi.toml, falling back to osx-64 (emulated with Rosetta)

This warning makes sense when a Python interpreter is actually run but it also happens when simply running pixi lock in a fresh project with this pixi.toml

[workspace]
channels = ["conda-forge"]
platforms = ["osx-64", "osx-arm64", "linux-64"]

[dependencies]
python = ">=3.12"

[feature.dev]

[feature.osx-64]
platforms = ["osx-64"]

[feature.osx-arm64]
platforms = ["osx-arm64"]

[feature.linux-64]
platforms = ["linux-64"]

[environments]
default = { features = ["dev"] }
osx-64-dev = { features = ["osx-64", "dev"] }
osx-arm64-dev = { features = ["osx-arm64", "dev"] }
linux-64-dev = { features = ["linux-64", "dev"] }

AFAIU this is because the function best_platform_with_current always checks if it should emit such a warning even if that function is also used in the resolution logic where no Python interpreter is actually run so the warning does not really make sense in that case. So the logic for emitting this warning should be pulled out of that function and re-added where it makes sense. The function currently mixes multiple purposes like this:

fn best_platform_with_current(&self, current: Platform) -> Platform {
// If the current platform is supported, return it.
if self.platforms().contains(&current) {
return current;
}
static WARN_ONCE: Once = Once::new();
// If the current platform is osx-arm64 and the environment supports osx-64,
// return osx-64.
if current.is_osx() && self.platforms().contains(&Platform::Osx64) {
WARN_ONCE.call_once(|| {
let warn_folder = self.workspace.pixi_dir().join(consts::ONE_TIME_MESSAGES_DIR);
let emulation_warn = warn_folder.join("macos-emulation-warn");
if !emulation_warn.exists() {
tracing::warn!(
"osx-arm64 (Apple Silicon) is not supported by the pixi.toml, falling back to osx-64 (emulated with Rosetta)"
);
// Create a file to prevent the warning from showing up multiple times. Also ignore the result.
fs_err::create_dir_all(warn_folder).and_then(|_| {
fs_err::File::create(emulation_warn)
}).ok();
}
});
return Platform::Osx64;
}

How Has This Been Tested?

I'm on macOS arm64. With the above pixi.toml and my changes I tried the following cases. It's important to always clear the .pixi/one-time-messages/ directory to truthfully test this.

  • pixi lock should not give warning anymore.
  • pixi install --environment osx-arm64-dev should not give warning anymore.
  • pixi install --environment osx-64-dev gives legitimate warning.
  • pixi install --environment linux-64-dev gives legitimate error.

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.
      Tools: Claude Code with Opus 4.6

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added sufficient tests to cover my changes.
  • I have verified that changes that would impact the JSON schema have been made in schema/model.py.

@wolfv wolfv merged commit 1920d47 into prefix-dev:main Mar 26, 2026
37 checks passed
@wolfv
Copy link
Copy Markdown
Member

wolfv commented Mar 26, 2026

Thank you @kilian-hu

@kilian-hu kilian-hu deleted the fix/remove-spurious-emulation-warning branch March 26, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants