Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions crates/pixi_manifest/src/manifests/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2921,15 +2921,15 @@ bar = "*"
let manifest = WorkspaceManifest::from_toml_str(toml);
let err = manifest.unwrap_err();
insta::assert_snapshot!(format_parse_error(toml, err.error), @r###"
× source dependencies are not allowed without enabling pixi-build
× conda source dependencies are not allowed without enabling the 'pixi-build' preview feature
╭─[pixi.toml:8:15]
7 │ [dependencies]
8 │ foo = { path = "./foo" }
· ─────────┬────────
· ╰── source dependency specified here
9 │
╰────
help: Add `workspace.preview = ["pixi-build"]` to enable pixi build support
help: Add `preview = ["pixi-build"]` to the `workspace` or `project` table of your manifest
"###);
}

Expand Down
4 changes: 2 additions & 2 deletions crates/pixi_manifest/src/utils/package_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ impl UniquePackageMap {
if let Some((package_name, _)) = self.specs.iter().find(|(_, spec)| spec.is_source()) {
return Err(TomlError::Generic(
GenericError::new(
"source dependencies are not allowed without enabling pixi-build",
"conda source dependencies are not allowed without enabling the 'pixi-build' preview feature",
)
.with_opt_span(self.value_spans.get(package_name).cloned())
.with_span_label("source dependency specified here")
.with_help(
"Add `workspace.preview = [\"pixi-build\"]` to enable pixi build support",
"Add `preview = [\"pixi-build\"]` to the `workspace` or `project` table of your manifest",
),
));
}
Expand Down
17 changes: 16 additions & 1 deletion src/cli/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use clap::Parser;
use indexmap::IndexMap;
use miette::IntoDiagnostic;
use pixi_config::ConfigCli;
use pixi_manifest::{FeatureName, SpecType};
use pixi_manifest::{FeatureName, KnownPreviewFeature, SpecType};
use pixi_spec::{GitSpec, SourceSpec};
use rattler_conda_types::{MatchSpec, PackageName};

Expand Down Expand Up @@ -129,6 +129,21 @@ pub async fn execute(args: Args) -> miette::Result<()> {
.collect();

if let Some(git) = &dependency_config.git {
if !workspace
.manifest()
.workspace
.preview()
.is_enabled(KnownPreviewFeature::PixiBuild)
{
return Err(miette::miette!(
help = format!(
"Add `preview = [\"pixi-build\"]` to the `workspace` or `project` table of your manifest ({})",
workspace.workspace().workspace.provenance.path.display()
),
"conda source dependencies are not allowed without enabling the 'pixi-build' preview feature"
));
}

let source_specs = passed_specs
.iter()
.map(|(name, (_spec, spec_type))| {
Expand Down
67 changes: 67 additions & 0 deletions tests/integration_rust/add_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,73 @@ platforms = ["{platform}"]
});
}

#[tokio::test]
async fn add_git_dependency_without_preview_feature_fails() {
let pixi = PixiControl::from_manifest(
r#"
[workspace]
name = "test-git-no-preview"
channels = ["https://prefix.dev/conda-forge"]
platforms = ["linux-64"]
"#,
)
.unwrap();

let result = pixi
.add("boost-check")
.with_git_url(Url::parse("https://github.com/wolfv/pixi-build-examples.git").unwrap())
.with_git_subdir("boost-check".to_string())
.await;

assert!(result.is_err());
let error = result.unwrap_err();

// Use insta to snapshot test the full error message format including help text
insta::with_settings!({
filters => vec![
// Filter out the dynamic manifest path to make the snapshot stable
(r"manifest \([^)]+\)", "manifest (<MANIFEST_PATH>)"),
]
}, {
insta::assert_debug_snapshot!("git_dependency_without_preview_error", error);
});
}

#[tokio::test]
async fn add_git_dependency_with_preview_feature_succeeds() {
let pixi = PixiControl::from_manifest(
r#"
[workspace]
name = "test-git-with-preview"
channels = ["https://prefix.dev/conda-forge"]
platforms = ["linux-64"]
preview = ["pixi-build"]
"#,
)
.unwrap();

let result = pixi
.add("boost-check")
.with_git_url(Url::parse("https://github.com/wolfv/pixi-build-examples.git").unwrap())
.with_git_subdir("boost-check".to_string())
.with_no_lockfile_update(true)
.await;

assert!(result.is_ok());

let workspace = pixi.workspace().unwrap();
let deps = workspace
.default_environment()
.combined_dependencies(Some(Platform::Linux64));

let (name, spec) = deps
.into_specs()
.find(|(name, _)| name.as_normalized() == "boost-check")
.unwrap();
assert_eq!(name.as_normalized(), "boost-check");
assert!(spec.is_source());
}

#[tokio::test]
async fn add_dependency_dont_create_project() {
// Create a channel with two packages
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
source: tests/integration_rust/add_tests.rs
expression: error
---
MietteDiagnostic {
message: "conda source dependencies are not allowed without enabling the 'pixi-build' preview feature",
code: None,
severity: None,
help: Some(
"Add `preview = [\"pixi-build\"]` to the `workspace` or `project` table of your manifest (<MANIFEST_PATH>)",
),
url: None,
labels: None,
}
Loading