Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tasks not found when switching from osx-arm64 to osx-64 #1404

Closed
2 tasks done
ekiefl opened this issue May 17, 2024 · 4 comments · Fixed by #1472
Closed
2 tasks done

Tasks not found when switching from osx-arm64 to osx-64 #1404

ekiefl opened this issue May 17, 2024 · 4 comments · Fixed by #1472
Labels
🐞 bug Something isn't working

Comments

@ekiefl
Copy link

ekiefl commented May 17, 2024

Checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pixi, using pixi --version.

Reproducible example

▶▶ pixi init pixi_py --pyproject
✔ Initialized project in /Users/evan/Software/test/pixi_py
▶▶ cd pixi_py/
▶▶ pixi install
✔ Project in /Users/evan/Software/test/pixi_py is ready to use!
▶▶ pixi task add hello "echo hi"
✔ Added task `hello`: echo hi
▶▶ pixi r hello
✨ Pixi task (hello in default): echo hi
hi

Now go into pyproject.toml and replace osx-arm64 with osx-64.

▶▶ pixi r hello
 WARN pixi::project::environment: osx-arm64 (Apple Silicon) is not supported by the pixi.toml, falling back to osx-64 (emulated with Rosetta)
hello: command not found

Issue description

image

On macOS, I have dependencies that don't have support for osx-arm64, which is what pixi determines my platform to be. So I have to manually fallback to osx-64. This poses no problems for installing pixi environments, however tasks are not recognized or run.

Expected behavior

After switching "osx-arm64" to "osx-64" in the pyproject, i.e.

[tool.pixi.project]
channels = ["conda-forge"]
platforms = ["osx-64"]

I expect the task to be recognized and run:

▶▶ pixi r hello
✨ Pixi task (hello in default): echo hi
hi
@ekiefl ekiefl added the 🐞 bug Something isn't working label May 17, 2024
@jjjermiah
Copy link
Contributor

if i understand correctly, you are switching the value of the [platforms] field.

Instead, you should have all platforms listed that you expect the project to work on.

There was a short discussion on discord that also explains this a bit.

So, after you initialize your project successfully and the task you add works, try running:

pixi project platform add osx-64

instead of replacing the platform in the project.

your platform field should be

[tool.pixi.project]
channels = ["conda-forge"]
platforms = [ "osx-arm64", "osx-64"]

Then pixi should solve the environment for all platforms (even the platform thats not your computer)

  • you might need to run pixi install for it to do the solving
  • this should update the pixi.lock file and the environments will be solved for all platforms
  • when the project is then transferred from your M3 Macbook (osx-arm64) to a Intel Macbook (osx-64), then pixi will recognize that the project is configured for that OS as well

@ruben-arts
Copy link
Contributor

@jjjermiah you are correct, however this will not work because of the case @ekiefl describes where he can not install for osx-arm64 because the packages are not available for it.

We've got some code to get the "best" platform which is why you can install osx-64 on osx-arm64 but we indeed missed fixing that for all code, apart from installation.

We should use the following function in more places!

/// Returns the best platform for the current platform & environment.
pub fn best_platform(&self) -> Platform {
let current = Platform::current();
// 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.project.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::create_dir_all(warn_folder).and_then(|_| {
std::fs::File::create(emulation_warn)
}).ok();
}
});
return Platform::Osx64;
}
if self.platforms().len() == 1 {
// Take the first platform and see if it is a WASM one.
if let Some(platform) = self.platforms().iter().next() {
if platform.arch() == Some(Arch::Wasm32) {
return *platform;
}
}
}
current
}

@ekiefl
Copy link
Author

ekiefl commented Jul 16, 2024

Hey, just popping in to say thank you for your responsiveness in fixing this issue. I updated our pixi version and no more troubles with osx-arm64 architectures :)

@wolfv
Copy link
Member

wolfv commented Jul 16, 2024

Awesome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants