Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5baed6e
feat: add `pixi reinstall`
Hofer-Julian Mar 12, 2025
06e9567
Add first mostly acceptable test
Hofer-Julian Mar 13, 2025
673148e
Add proper test
Hofer-Julian Mar 13, 2025
46c41de
Fix CLI
Hofer-Julian Mar 13, 2025
90df9b0
Test remaining scenarios
Hofer-Julian Mar 13, 2025
f26755e
Hook everything up
Hofer-Julian Mar 13, 2025
50b8b66
Get everything to compile
Hofer-Julian Mar 13, 2025
4a02d55
Get it to compile again
Hofer-Julian Mar 13, 2025
8dadeb6
feat: set refresh strategy for the context
tdejager Mar 13, 2025
00922b5
Adapt for conda
Hofer-Julian Mar 13, 2025
8c59bf6
Adapt tests
Hofer-Julian Mar 13, 2025
6d90eaa
Reorder test a bit
Hofer-Julian Mar 13, 2025
80ccaa6
Only use package names that are actually in our records
Hofer-Julian Mar 14, 2025
597547d
feat: set refresh strategy for the cache
tdejager Mar 14, 2025
5f1881c
fix: test for osx-arm64
tdejager Mar 14, 2025
4c551d1
Fix test
Hofer-Julian Mar 14, 2025
a6f0c0b
pixi build rebuild
Hofer-Julian Mar 14, 2025
7cbc7ac
Fix pixi toml
Hofer-Julian Mar 14, 2025
61b7b0f
Fix tests (mostly)
Hofer-Julian Mar 14, 2025
9b13afd
Finalize tests
Hofer-Julian Mar 14, 2025
0874270
Merge branch 'main' into feat/pixi-reinstall
Hofer-Julian Mar 14, 2025
e284fca
Adapt CLI docs
Hofer-Julian Mar 14, 2025
f9da01b
Adapt string
Hofer-Julian Mar 14, 2025
736c303
Fix string changes
Hofer-Julian Mar 14, 2025
d120620
Merge branch 'main' into feat/pixi-reinstall
Hofer-Julian Mar 14, 2025
9c9200f
Fix CLI docs
Hofer-Julian Mar 14, 2025
ef9e29a
Merge branch 'main' into feat/pixi-reinstall
ruben-arts Mar 17, 2025
58cbb32
Merge branch 'main' into feat/pixi-reinstall
Hofer-Julian Mar 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/reference/cli/pixi.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pixi [OPTIONS] <COMMAND>
| [`add`](pixi/add.md) | Adds dependencies to the workspace |
| [`remove`](pixi/remove.md) | Removes dependencies from the workspace |
| [`install`](pixi/install.md) | Install an environment, both updating the lockfile and installing the environment |
| [`reinstall`](pixi/reinstall.md) | Re-install an environment, both updating the lockfile and re-installing the environment |
| [`update`](pixi/update.md) | The `update` command checks if there are newer versions of the dependencies and updates the `pixi.lock` file and environments accordingly |
| [`upgrade`](pixi/upgrade.md) | Checks if there are newer versions of the dependencies and upgrades them in the lockfile and manifest file |
| [`lock`](pixi/lock.md) | Solve environment and update the lock file without installing the environments |
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/cli/pixi/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ If you want to install all environments, you can use the `--all` flag.

Running `pixi install` is not required before running other commands like `pixi run` or `pixi shell`. These commands will automatically install the environment if it is not already installed.

You can use `pixi clean` to remove the installed environments and start fresh.
You can use `pixi reinstall` to reinstall all environments, one environment or just some packages of an environment.


--8<-- "docs/reference/cli/pixi/install_extender.md:example"
59 changes: 59 additions & 0 deletions docs/reference/cli/pixi/reinstall.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!--- This file is autogenerated. Do not edit manually! -->
# <code>[pixi](../pixi.md) reinstall</code>

## About
Re-install an environment, both updating the lockfile and re-installing the environment

--8<-- "docs/reference/cli/pixi/reinstall_extender.md:description"

## Usage
```
pixi reinstall [OPTIONS] [PACKAGE]...
```

## Arguments
- <a id="arg-<PACKAGE>" href="#arg-<PACKAGE>">`<PACKAGE>`</a>
: Specifies the package that should be reinstalled. If no package is given, the whole environment will be reinstalled
<br>May be provided more than once.

## Config Options
- <a id="arg---tls-no-verify" href="#arg---tls-no-verify">`--tls-no-verify`</a>
: Do not verify the TLS certificate of the server
- <a id="arg---auth-file" href="#arg---auth-file">`--auth-file <AUTH_FILE>`</a>
: Path to the file containing the authentication token
- <a id="arg---pypi-keyring-provider" href="#arg---pypi-keyring-provider">`--pypi-keyring-provider <PYPI_KEYRING_PROVIDER>`</a>
: Specifies whether to use the keyring to look up credentials for PyPI
<br>**options**: `disabled`, `subprocess`
- <a id="arg---concurrent-solves" href="#arg---concurrent-solves">`--concurrent-solves <CONCURRENT_SOLVES>`</a>
: Max concurrent solves, default is the number of CPUs
- <a id="arg---concurrent-downloads" href="#arg---concurrent-downloads">`--concurrent-downloads <CONCURRENT_DOWNLOADS>`</a>
: Max concurrent network requests, default is `50`

## Update Options
- <a id="arg---frozen" href="#arg---frozen">`--frozen`</a>
: Install the environment as defined in the lockfile, doesn't update lockfile if it isn't up-to-date with the manifest file
<br>**env**: `PIXI_FROZEN`
- <a id="arg---locked" href="#arg---locked">`--locked`</a>
: Check if lockfile is up-to-date before installing the environment, aborts when lockfile isn't up-to-date with the manifest file
<br>**env**: `PIXI_LOCKED`
- <a id="arg---environment" href="#arg---environment">`--environment (-e) <ENVIRONMENT>`</a>
: The environment to install
<br>May be provided more than once.
- <a id="arg---all" href="#arg---all">`--all (-a)`</a>
: Install all environments

## Global Options
- <a id="arg---manifest-path" href="#arg---manifest-path">`--manifest-path <MANIFEST_PATH>`</a>
: The path to `pixi.toml`, `pyproject.toml`, or the workspace directory

## Description
Re-install an environment, both updating the lockfile and re-installing the environment.

This command reinstalls an environment, if the lockfile is not up-to-date it will be updated. If packages are specified, only those packages will be reinstalled. Otherwise the whole environment will be reinstalled.

`pixi reinstall` only re-installs one environment at a time, if you have multiple environments you can select the right one with the `--environment` flag. If you don't provide an environment, the `default` environment will be re-installed.

If you want to re-install all environments, you can use the `--all` flag.


--8<-- "docs/reference/cli/pixi/reinstall_extender.md:example"
11 changes: 7 additions & 4 deletions src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ impl BuildContext {
build_reporter: Arc<dyn BuildReporter>,
source_reporter: Option<Arc<dyn SourceReporter>>,
build_id: usize,
rebuild: bool,
) -> Result<RepoDataRecord, BuildError> {
let source_checkout = SourceCheckout {
path: self
Expand Down Expand Up @@ -287,10 +288,12 @@ impl BuildContext {
.await?;

// Check if there are already cached builds
if let Some(build) = cached_build {
if let Some(record) = Self::cached_build_source_record(build, &source_checkout)? {
build_reporter.on_build_cached(build_id);
return Ok(record);
if !rebuild {
if let Some(build) = cached_build {
if let Some(record) = Self::cached_build_source_record(build, &source_checkout)? {
build_reporter.on_build_cached(build_id);
return Ok(record);
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/cli/install.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::cli::cli_config::WorkspaceConfig;
use crate::environment::get_update_lock_file_and_prefix;
use crate::lock_file::UpdateMode;
use crate::lock_file::{ReinstallPackages, UpdateMode};
use crate::{UpdateLockFileOptions, WorkspaceLocator};
use clap::Parser;
use fancy_display::FancyDisplay;
Expand All @@ -20,7 +20,7 @@ use pixi_config::ConfigCli;
/// Running `pixi install` is not required before running other commands like `pixi run` or `pixi shell`.
/// These commands will automatically install the environment if it is not already installed.
///
/// You can use `pixi clean` to remove the installed environments and start fresh.
/// You can use `pixi reinstall` to reinstall all environments, one environment or just some packages of an environment.
#[derive(Parser, Debug)]
pub struct Args {
#[clap(flatten)]
Expand Down Expand Up @@ -77,6 +77,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
no_install: false,
max_concurrent_solves: workspace.config().max_concurrent_solves(),
},
ReinstallPackages::default(),
)
.await?;

Expand Down
3 changes: 3 additions & 0 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub mod init;
pub mod install;
pub mod list;
pub mod lock;
pub mod reinstall;
pub mod remove;
pub mod run;
pub mod search;
Expand Down Expand Up @@ -134,6 +135,7 @@ pub enum Command {
Remove(remove::Args),
#[clap(visible_alias = "i")]
Install(install::Args),
Reinstall(reinstall::Args),
Update(update::Args),
Upgrade(upgrade::Args),
Lock(lock::Args),
Expand Down Expand Up @@ -270,6 +272,7 @@ pub async fn execute_command(command: Command) -> miette::Result<()> {
Command::Global(cmd) => global::execute(cmd).await,
Command::Auth(cmd) => rattler::cli::auth::execute(cmd).await.into_diagnostic(),
Command::Install(cmd) => install::execute(cmd).await,
Command::Reinstall(cmd) => reinstall::execute(cmd).await,
Command::Shell(cmd) => shell::execute(cmd).await,
Command::ShellHook(cmd) => shell_hook::execute(cmd).await,
Command::Task(cmd) => task::execute(cmd).await,
Expand Down
120 changes: 120 additions & 0 deletions src/cli/reinstall.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
use crate::cli::cli_config::WorkspaceConfig;
use crate::environment::get_update_lock_file_and_prefix;
use crate::lock_file::{ReinstallPackages, UpdateMode};
use crate::{UpdateLockFileOptions, WorkspaceLocator};
use clap::Parser;
use fancy_display::FancyDisplay;
use itertools::Itertools;
use pixi_config::ConfigCli;

/// Re-install an environment, both updating the lockfile and re-installing the environment.
///
/// This command reinstalls an environment, if the lockfile is not up-to-date it will be updated.
/// If packages are specified, only those packages will be reinstalled.
/// Otherwise the whole environment will be reinstalled.
///
/// `pixi reinstall` only re-installs one environment at a time,
/// if you have multiple environments you can select the right one with the `--environment` flag.
/// If you don't provide an environment, the `default` environment will be re-installed.
///
/// If you want to re-install all environments, you can use the `--all` flag.
#[derive(Parser, Debug)]
pub struct Args {
/// Specifies the package that should be reinstalled.
/// If no package is given, the whole environment will be reinstalled.
#[arg(value_name = "PACKAGE")]
packages: Option<Vec<String>>,

#[clap(flatten)]
pub project_config: WorkspaceConfig,

#[clap(flatten)]
pub lock_file_usage: super::LockFileUsageConfig,

/// The environment to install.
#[arg(long, short)]
pub environment: Option<Vec<String>>,

#[clap(flatten)]
pub config: ConfigCli,

/// Install all environments.
#[arg(long, short, conflicts_with = "environment")]
pub all: bool,
}

pub async fn execute(args: Args) -> miette::Result<()> {
let workspace = WorkspaceLocator::for_cli()
.with_search_start(args.project_config.workspace_locator_start())
.locate()?
.with_cli_config(args.config);

// Install either:
//
// 1. specific environments
// 2. all environments
// 3. default environment (if no environments are specified)
let envs = if let Some(envs) = args.environment {
envs
} else if args.all {
workspace
.environments()
.iter()
.map(|env| env.name().to_string())
.collect()
} else {
vec![workspace.default_environment().name().to_string()]
};

let reinstall_packages = args
.packages
.map(|p| p.into_iter().collect())
.map(ReinstallPackages::Some)
.unwrap_or(ReinstallPackages::All);

let mut installed_envs = Vec::with_capacity(envs.len());
for env in envs {
let environment = workspace.environment_from_name_or_env_var(Some(env))?;

// Update the prefix by installing all packages
get_update_lock_file_and_prefix(
&environment,
UpdateMode::Revalidate,
UpdateLockFileOptions {
lock_file_usage: args.lock_file_usage.into(),
no_install: false,
max_concurrent_solves: workspace.config().max_concurrent_solves(),
},
reinstall_packages.clone(),
)
.await?;

installed_envs.push(environment.name().clone());
}

// Message what's installed
let detached_envs_message =
if let Ok(Some(path)) = workspace.config().detached_environments().path() {
format!(" in '{}'", console::style(path.display()).bold())
} else {
"".to_string()
};

if installed_envs.len() == 1 {
eprintln!(
"{}The {} environment has been re-installed{}.",
console::style(console::Emoji("✔ ", "")).green(),
installed_envs[0].fancy_display(),
detached_envs_message
);
} else {
eprintln!(
"{}The following environments have been re-installed: {}\t{}",
console::style(console::Emoji("✔ ", "")).green(),
installed_envs.iter().map(|n| n.fancy_display()).join(", "),
detached_envs_message
);
}

Ok(())
}
3 changes: 2 additions & 1 deletion src/cli/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{cli_config::LockFileUpdateConfig, has_specs::HasSpecs};
use crate::{
cli::cli_config::{DependencyConfig, PrefixUpdateConfig, WorkspaceConfig},
environment::get_update_lock_file_and_prefix,
lock_file::UpdateMode,
lock_file::{ReinstallPackages, UpdateMode},
DependencyType, UpdateLockFileOptions, WorkspaceLocator,
};
use clap::Parser;
Expand Down Expand Up @@ -124,6 +124,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
no_install: prefix_update_config.no_install,
max_concurrent_solves: workspace.config().max_concurrent_solves(),
},
ReinstallPackages::default(),
)
.await?;
}
Expand Down
3 changes: 2 additions & 1 deletion src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use tracing::Level;
use crate::{
cli::cli_config::{PrefixUpdateConfig, WorkspaceConfig},
environment::sanity_check_project,
lock_file::UpdateLockFileOptions,
lock_file::{ReinstallPackages, UpdateLockFileOptions},
task::{
get_task_env, AmbiguousTask, CanSkip, ExecutableTask, FailedToParseShellScript,
InvalidWorkingDirectory, SearchEnvironments, TaskAndEnvironment, TaskGraph,
Expand Down Expand Up @@ -250,6 +250,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
.prefix(
&executable_task.run_environment,
args.prefix_update_config.update_mode(),
ReinstallPackages::default(),
)
.await?;

Expand Down
6 changes: 5 additions & 1 deletion src/cli/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ use rattler_shell::{
shell::{CmdExe, PowerShell, Shell, ShellEnum, ShellScript},
};

use crate::cli::cli_config::{PrefixUpdateConfig, WorkspaceConfig};
use crate::lock_file::UpdateMode;
use crate::workspace::get_activated_environment_variables;
use crate::{
activation::CurrentEnvVarBehavior, environment::get_update_lock_file_and_prefix, prompt,
UpdateLockFileOptions, WorkspaceLocator,
};
use crate::{
cli::cli_config::{PrefixUpdateConfig, WorkspaceConfig},
lock_file::ReinstallPackages,
};
use pixi_config::{ConfigCli, ConfigCliActivation, ConfigCliPrompt};
#[cfg(target_family = "unix")]
use pixi_pty::unix::PtySession;
Expand Down Expand Up @@ -284,6 +287,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
&& args.lock_file_update_config.no_lockfile_update,
max_concurrent_solves: workspace.config().max_concurrent_solves(),
},
ReinstallPackages::default(),
)
.await?;

Expand Down
2 changes: 2 additions & 0 deletions src/cli/shell_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::{
activation::{get_activator, CurrentEnvVarBehavior},
cli::cli_config::{PrefixUpdateConfig, WorkspaceConfig},
environment::get_update_lock_file_and_prefix,
lock_file::ReinstallPackages,
prompt,
workspace::{get_activated_environment_variables, Environment, HasWorkspaceRef},
UpdateLockFileOptions, Workspace, WorkspaceLocator,
Expand Down Expand Up @@ -163,6 +164,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
&& args.lock_file_update_config.no_lockfile_update,
max_concurrent_solves: workspace.config().max_concurrent_solves(),
},
ReinstallPackages::default(),
)
.await?;

Expand Down
3 changes: 2 additions & 1 deletion src/cli/workspace/channel/add.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
environment::{get_update_lock_file_and_prefix, LockFileUsage},
lock_file::UpdateMode,
lock_file::{ReinstallPackages, UpdateMode},
UpdateLockFileOptions, WorkspaceLocator,
};
use miette::IntoDiagnostic;
Expand Down Expand Up @@ -31,6 +31,7 @@ pub async fn execute(args: AddRemoveArgs) -> miette::Result<()> {
&& args.lock_file_update_config.no_lockfile_update,
max_concurrent_solves: workspace.workspace().config().max_concurrent_solves(),
},
ReinstallPackages::default(),
)
.await?;

Expand Down
3 changes: 2 additions & 1 deletion src/cli/workspace/channel/remove.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::lock_file::UpdateMode;
use crate::lock_file::{ReinstallPackages, UpdateMode};
use crate::{
environment::{get_update_lock_file_and_prefix, LockFileUsage},
UpdateLockFileOptions, WorkspaceLocator,
Expand Down Expand Up @@ -29,6 +29,7 @@ pub async fn execute(args: AddRemoveArgs) -> miette::Result<()> {
&& args.lock_file_update_config.no_lockfile_update,
max_concurrent_solves: workspace.workspace().config().max_concurrent_solves(),
},
ReinstallPackages::default(),
)
.await?;
let workspace = workspace.save().await.into_diagnostic()?;
Expand Down
3 changes: 2 additions & 1 deletion src/cli/workspace/platform/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::str::FromStr;

use crate::{
environment::{get_update_lock_file_and_prefix, LockFileUsage},
lock_file::UpdateMode,
lock_file::{ReinstallPackages, UpdateMode},
UpdateLockFileOptions, Workspace,
};
use clap::Parser;
Expand Down Expand Up @@ -55,6 +55,7 @@ pub async fn execute(workspace: Workspace, args: Args) -> miette::Result<()> {
no_install: args.no_install,
max_concurrent_solves: workspace.workspace().config().max_concurrent_solves(),
},
ReinstallPackages::default(),
)
.await?;
workspace.save().await.into_diagnostic()?;
Expand Down
Loading
Loading