File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -450,16 +450,20 @@ impl Config {
450
450
if let Some ( dir) = & self . target_dir {
451
451
Ok ( Some ( dir. clone ( ) ) )
452
452
} else if let Some ( dir) = env:: var_os ( "CARGO_TARGET_DIR" ) {
453
+ // Check if the CARGO_TARGET_DIR environment variable is set to an empty string.
453
454
if dir. to_string_lossy ( ) == "" {
454
- anyhow:: bail!( "the target directory is set to an empty string" )
455
+ anyhow:: bail!( "the target directory is set to an empty string in the CARGO_TARGET_DIR environment variable. " )
455
456
}
456
457
457
458
Ok ( Some ( Filesystem :: new ( self . cwd . join ( dir) ) ) )
458
459
} else if let Some ( val) = & self . build_config ( ) ?. target_dir {
459
460
let path = val. resolve_path ( self ) ;
460
461
462
+ // Check if the target directory is set to an empty string in the config.toml file.
461
463
if val. raw_value ( ) == "" {
462
- anyhow:: bail!( "the target directory is set to an empty string" )
464
+ anyhow:: bail!(
465
+ "the target directory is set to an empty string in the config.toml file." ,
466
+ )
463
467
}
464
468
465
469
Ok ( Some ( Filesystem :: new ( path) ) )
Original file line number Diff line number Diff line change @@ -1497,6 +1497,17 @@ target-dir = ''
1497
1497
1498
1498
assert_error (
1499
1499
config. target_dir ( ) . unwrap_err ( ) ,
1500
- "the target directory is set to an empty string" ,
1500
+ "the target directory is set to an empty string in the config.toml file. " ,
1501
1501
) ;
1502
1502
}
1503
+
1504
+ #[ cargo_test]
1505
+ fn cargo_target_empty_env ( ) {
1506
+ let project = project ( ) . build ( ) ;
1507
+
1508
+ project. cargo ( "build" )
1509
+ . env ( "CARGO_TARGET_DIR" , "" )
1510
+ . with_stderr ( "error: the target directory is set to an empty string in the CARGO_TARGET_DIR environment variable." )
1511
+ . with_status ( 101 )
1512
+ . run ( )
1513
+ }
You can’t perform that action at this time.
0 commit comments