File tree 2 files changed +35
-2
lines changed
2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -1685,8 +1685,15 @@ impl Config {
1685
1685
}
1686
1686
1687
1687
pub fn env_config ( & self ) -> CargoResult < & EnvConfig > {
1688
- self . env_config
1689
- . try_borrow_with ( || self . get :: < EnvConfig > ( "env" ) )
1688
+ let env_config = self
1689
+ . env_config
1690
+ . try_borrow_with ( || self . get :: < EnvConfig > ( "env" ) ) ?;
1691
+
1692
+ if env_config. get ( "CARGO_HOME" ) . is_some ( ) {
1693
+ bail ! ( "setting the `CARGO_HOME` environment variable is not supported in the `[env]` configuration table" )
1694
+ }
1695
+
1696
+ Ok ( env_config)
1690
1697
}
1691
1698
1692
1699
/// This is used to validate the `term` table has valid syntax.
Original file line number Diff line number Diff line change @@ -57,6 +57,32 @@ fn env_invalid() {
57
57
. run ( ) ;
58
58
}
59
59
60
+ #[ cargo_test]
61
+ fn env_no_cargo_home ( ) {
62
+ let p = project ( )
63
+ . file ( "Cargo.toml" , & basic_bin_manifest ( "foo" ) )
64
+ . file (
65
+ "src/main.rs" ,
66
+ r#"
67
+ fn main() {
68
+ }
69
+ "# ,
70
+ )
71
+ . file (
72
+ ".cargo/config" ,
73
+ r#"
74
+ [env]
75
+ CARGO_HOME = "/"
76
+ "# ,
77
+ )
78
+ . build ( ) ;
79
+
80
+ p. cargo ( "build" )
81
+ . with_status ( 101 )
82
+ . with_stderr_contains ( "[..]setting the `CARGO_HOME` environment variable is not supported in the `[env]` configuration table" )
83
+ . run ( ) ;
84
+ }
85
+
60
86
#[ cargo_test]
61
87
fn env_force ( ) {
62
88
let p = project ( )
You can’t perform that action at this time.
0 commit comments