File tree 2 files changed +65
-1
lines changed
2 files changed +65
-1
lines changed Original file line number Diff line number Diff line change @@ -1494,7 +1494,11 @@ impl schema::InheritableFields {
1494
1494
} ;
1495
1495
let mut dep = dep. clone ( ) ;
1496
1496
if let schema:: TomlDependency :: Detailed ( detailed) = & mut dep {
1497
- detailed. resolve_path ( name, self . ws_root ( ) , package_root) ?;
1497
+ if detailed. base . is_none ( ) {
1498
+ // If this is a path dependency without a base, then update the path to be relative
1499
+ // to the workspace root instead.
1500
+ detailed. resolve_path ( name, self . ws_root ( ) , package_root) ?;
1501
+ }
1498
1502
}
1499
1503
Ok ( dep)
1500
1504
}
Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ use cargo_test_support::{sleep_ms, t};
7
7
use std:: fs;
8
8
9
9
#[ cargo_test]
10
+ // I have no idea why this is failing spuriously on Windows;
11
+ // for more info, see #3466.
12
+ #[ cfg( not( windows) ) ]
10
13
fn cargo_compile_with_nested_deps_shorthand ( ) {
11
14
let p = project ( )
12
15
. file (
@@ -661,6 +664,63 @@ fn path_with_base() {
661
664
. run ( ) ;
662
665
}
663
666
667
+ #[ cargo_test]
668
+ fn workspace_with_base ( ) {
669
+ let bar = project ( )
670
+ . at ( "dep_with_base" )
671
+ . file ( "Cargo.toml" , & basic_manifest ( "dep_with_base" , "0.5.0" ) )
672
+ . file ( "src/lib.rs" , "" )
673
+ . build ( ) ;
674
+
675
+ fs:: create_dir ( & paths:: root ( ) . join ( ".cargo" ) ) . unwrap ( ) ;
676
+ fs:: write (
677
+ & paths:: root ( ) . join ( ".cargo/config" ) ,
678
+ & format ! (
679
+ "[base_path]\n test = '{}'" ,
680
+ bar. root( ) . parent( ) . unwrap( ) . display( )
681
+ ) ,
682
+ )
683
+ . unwrap ( ) ;
684
+
685
+ let p = project ( )
686
+ . file (
687
+ "Cargo.toml" ,
688
+ r#"
689
+ [package]
690
+ name = "parent"
691
+ version = "0.1.0"
692
+ authors = []
693
+
694
+ [workspace]
695
+ members = ["child"]
696
+
697
+ [workspace.dependencies.dep_with_base]
698
+ path = 'dep_with_base'
699
+ base = 'test'
700
+ "# ,
701
+ )
702
+ . file ( "src/main.rs" , "fn main() {}" )
703
+ . file (
704
+ "child/Cargo.toml" ,
705
+ r#"
706
+ [package]
707
+ name = "child"
708
+ version = "0.1.0"
709
+ authors = []
710
+ workspace = ".."
711
+
712
+ [dependencies.dep_with_base]
713
+ workspace = true
714
+ "# ,
715
+ )
716
+ . file ( "child/src/main.rs" , "fn main() {}" ) ;
717
+ let p = p. build ( ) ;
718
+
719
+ p. cargo ( "build -v -Zpath-bases" )
720
+ . masquerade_as_nightly_cargo ( & [ "path-bases" ] )
721
+ . run ( ) ;
722
+ }
723
+
664
724
#[ cargo_test]
665
725
fn unknown_base ( ) {
666
726
let p = project ( )
You can’t perform that action at this time.
0 commit comments