-
Couldn't load subscription status.
- Fork 368
feat(install): add --to-prefix option
#4462
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
base: main
Are you sure you want to change the base?
Conversation
- Add PrefixOverrideGuard for thread-local prefix management - Support platform overrides with --platform flag - Enable installing environments to custom directories - Add validation for platform compatibility - Update CLI documentation and integration tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this approach is very hacky. The PrefixOverrideGuard approach uses global variables to cause side effects.
I think instead we could split the code path slightly where we have a path for --to-prefix and the original code.
The --to-prefix path would have to get an up-to-date lock-file, extract the specs from the lock-file for the desired environment and call CommandDispatcher::install_pixi_environment.
Alternatively I can also imagine that this could go into a separate sub-command?
@ruben-arts From a UX point of view, what are your thoughts?
| if let Some(prefix_path) = &args.to_prefix { | ||
| tokio::fs::create_dir_all(prefix_path) | ||
| .await | ||
| .into_diagnostic() | ||
| .with_context(|| { | ||
| format!( | ||
| "Failed to create prefix directory: {}", | ||
| prefix_path.display() | ||
| ) | ||
| })?; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? I would assume this happens during installation.
| } | ||
|
|
||
| pub async fn execute(args: Args) -> miette::Result<()> { | ||
| use miette::{Context, IntoDiagnostic}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets just move this up to the top of the file.
| let envs = if args.to_prefix.is_some() { | ||
| vec![ | ||
| args.environment | ||
| .and_then(|envs| envs.into_iter().next()) | ||
| .unwrap_or_else(|| "default".to_string()), | ||
| ] | ||
| } else if let Some(envs) = args.environment { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this code? It no longer matches the comment above.
--to-prefix option
|
see also #3953 |
|
I'm all for Pixi supporting the ability to install to a specific environment. But it needs more than just the installation to work. E.g. activation is needed to make this usable and we should figure out what tools would interact with the same thing.
|
Add
--to-prefixoption for custom environment installationSummary
This PR introduces the
--to-prefixoption to thepixi installcommand, enabling installation of environments to custom directories instead of the default.pixi/envs/<env-name>location. This addresses a long-standing community need with an officially-supported solution that supersedes existing third-party tools.Motivation
The community has requested flexible environment installation locations for container deployments, CI/CD pipelines, system integration, and production scenarios. Previously, users relied on third-party tools like
pixi-install-to-prefix, which had critical limitations:Implementation
Core Features
Custom Prefix Installation
Platform Override Support
Platform Validation
Technical Architecture
PrefixOverrideGuard: Thread-local RAII pattern for safe prefix management
Environment Integration: Modified
Environment::dir()andEnvironment::best_platform()to check thread-local overrides before falling back to default behavior.