Skip to content

Commit 853309d

Browse files
committed
Update workspace discovery to use workspace registry file
1 parent 66eab92 commit 853309d

3 files changed

Lines changed: 9 additions & 10 deletions

File tree

crates/pixi_api/src/workspace/registry/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl Default for WorkspaceRegistry {
3333

3434
impl WorkspaceRegistry {
3535
/// Loads the workspace registry from disk, if it exists.
36-
pub async fn load() -> miette::Result<Self> {
36+
pub fn load() -> miette::Result<Self> {
3737
let path = workspace_registry_path()
3838
.ok_or_else(|| miette::miette!("Unable to determine pixi home directory"))?;
3939

crates/pixi_cli/src/cli_config.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ use indexmap::IndexSet;
55
use itertools::Itertools;
66
use miette::IntoDiagnostic;
77
use pep508_rs::Requirement;
8+
use pixi_api::workspace::WorkspaceRegistry;
89
use pixi_build_frontend::BackendOverride;
9-
use pixi_config::{Config, pixi_home};
10+
use pixi_config::Config;
1011
use pixi_consts::consts;
1112
use pixi_core::DependencyType;
1213
use pixi_core::Workspace;
@@ -47,11 +48,9 @@ impl WorkspaceConfig {
4748
if let Some(manifest_path) = &self.manifest_path {
4849
DiscoveryStart::ExplicitManifest(manifest_path.clone())
4950
} else if let Some(workspace) = &self.workspace {
50-
let path = pixi_home()
51-
.expect("Unable to pixi home")
52-
.join(consts::DEFAULT_GLOBAL_WORKSPACE_DIR)
53-
.join(workspace);
54-
DiscoveryStart::ExplicitManifest(path.clone())
51+
let workspace_registry = WorkspaceRegistry::load().expect("Unable to load workspace registry");
52+
let path = workspace_registry.named_workspace(&workspace).expect("Unable to find workspace");
53+
DiscoveryStart::ExplicitManifest(path)
5554
} else {
5655
DiscoveryStart::CurrentDir
5756
}

crates/pixi_cli/src/workspace/register.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub enum Command {
6060
pub async fn execute(args: Args) -> miette::Result<()> {
6161
match args.command {
6262
Some(Command::List(args)) => {
63-
let workspace_registry = WorkspaceRegistry::load().await?;
63+
let workspace_registry = WorkspaceRegistry::load()?;
6464
let workspaces = workspace_registry.named_workspaces_map();
6565
let out = if args.json {
6666
serde_json::to_string_pretty(&workspaces).into_diagnostic()?
@@ -77,7 +77,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
7777
.into_diagnostic()?;
7878
}
7979
Some(Command::Remove(remove_args)) => {
80-
let mut workspace_registry = WorkspaceRegistry::load().await?;
80+
let mut workspace_registry = WorkspaceRegistry::load()?;
8181
workspace_registry.remove_workspace(&remove_args.name).await?;
8282

8383
eprintln!(
@@ -115,7 +115,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
115115
.unwrap_or_else(|| workspace.display_name().to_string());
116116
let target_path = args.path.unwrap_or_else(|| workspace.root().to_path_buf());
117117

118-
let mut workspace_registry = WorkspaceRegistry::load().await?;
118+
let mut workspace_registry = WorkspaceRegistry::load()?;
119119
workspace_registry.add_workspace(target_name, target_path).await?;
120120

121121
eprintln!(

0 commit comments

Comments
 (0)