File tree Expand file tree Collapse file tree 4 files changed +43
-4
lines changed
uv-distribution/src/metadata Expand file tree Collapse file tree 4 files changed +43
-4
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,13 @@ impl SourcedDependencyGroups {
58
58
source_strategy : SourceStrategy ,
59
59
cache : & WorkspaceCache ,
60
60
) -> Result < Self , MetadataError > {
61
+ // If the `pyproject.toml` doesn't exist, fail early.
62
+ if !pyproject_path. is_file ( ) {
63
+ return Err ( MetadataError :: MissingPyprojectToml (
64
+ pyproject_path. to_path_buf ( ) ,
65
+ ) ) ;
66
+ }
67
+
61
68
let discovery = DiscoveryOptions {
62
69
stop_discovery_at : git_member. map ( |git_member| {
63
70
git_member
Original file line number Diff line number Diff line change 1
1
use std:: collections:: BTreeMap ;
2
- use std:: path:: Path ;
2
+ use std:: path:: { Path , PathBuf } ;
3
3
4
4
use thiserror:: Error ;
5
5
@@ -28,6 +28,8 @@ pub enum MetadataError {
28
28
Workspace ( #[ from] WorkspaceError ) ,
29
29
#[ error( transparent) ]
30
30
DependencyGroup ( #[ from] DependencyGroupError ) ,
31
+ #[ error( "No pyproject.toml found at `{0}`" ) ]
32
+ MissingPyprojectToml ( PathBuf ) ,
31
33
#[ error( "Failed to parse entry: `{0}`" ) ]
32
34
LoweringError ( PackageName , #[ source] Box < LoweringError > ) ,
33
35
#[ error( "Failed to parse entry in group `{0}`: `{1}`" ) ]
Original file line number Diff line number Diff line change @@ -218,16 +218,16 @@ pub(crate) async fn resolve<InstalledPackages: InstalledPackagesProvider>(
218
218
. await
219
219
. with_context ( || {
220
220
format ! (
221
- "Failed to read dependency groups from: {} " ,
222
- pyproject_path. display ( )
221
+ "Failed to read dependency groups from: `{}` " ,
222
+ pyproject_path. user_display ( )
223
223
)
224
224
} ) ?;
225
225
226
226
// Complain if dependency groups are named that don't appear.
227
227
for name in groups. explicit_names ( ) {
228
228
if !metadata. dependency_groups . contains_key ( name) {
229
229
return Err ( anyhow ! (
230
- "The dependency group '{name}' was not found in the project: {} " ,
230
+ "The dependency group '{name}' was not found in the project: `{}` " ,
231
231
pyproject_path. user_display( )
232
232
) ) ?;
233
233
}
Original file line number Diff line number Diff line change @@ -16179,6 +16179,36 @@ fn directory_and_group() -> Result<()> {
16179
16179
Ok(())
16180
16180
}
16181
16181
16182
+ #[test]
16183
+ fn group_target_does_not_exist() -> Result<()> {
16184
+ let context = TestContext::new("3.12");
16185
+
16186
+ let pyproject_toml = context.temp_dir.child("pyproject.toml");
16187
+ pyproject_toml.write_str(
16188
+ r#"
16189
+ [project]
16190
+ name = "myproject"
16191
+ version = "0.1.0"
16192
+ requires-python = ">=3.12"
16193
+
16194
+
16195
+ "#,
16196
+ )?;
16197
+
16198
+ uv_snapshot!(context.filters(), context.pip_compile()
16199
+ .arg("--group").arg("does/not/exist/pyproject.toml:foo"), @r"
16200
+ success: false
16201
+ exit_code: 2
16202
+ ----- stdout -----
16203
+
16204
+ ----- stderr -----
16205
+ error: Failed to read dependency groups from: `does/not/exist/pyproject.toml`
16206
+ Caused by: No pyproject.toml found at `does/not/exist/pyproject.toml`
16207
+ ");
16208
+
16209
+ Ok(())
16210
+ }
16211
+
16182
16212
/// See: <https://github.com/astral-sh/uv/issues/10957>
16183
16213
#[cfg(feature = "python-eol")]
16184
16214
#[test]
You can’t perform that action at this time.
0 commit comments