@@ -568,12 +568,30 @@ pub(crate) fn register(engine: &Engine, target: &Target, msg_info: &mut MessageI
568
568
docker. run ( msg_info, false ) . map_err ( Into :: into)
569
569
}
570
570
571
- fn validate_env_var ( var : & str ) -> Result < ( & str , Option < & str > ) > {
571
+ fn validate_env_var < ' a > (
572
+ var : & ' a str ,
573
+ warned : & mut bool ,
574
+ var_type : & ' static str ,
575
+ var_syntax : & ' static str ,
576
+ msg_info : & mut MessageInfo ,
577
+ ) -> Result < ( & ' a str , Option < & ' a str > ) > {
572
578
let ( key, value) = match var. split_once ( '=' ) {
573
579
Some ( ( key, value) ) => ( key, Some ( value) ) ,
574
580
_ => ( var, None ) ,
575
581
} ;
576
582
583
+ if value. is_none ( )
584
+ && !* warned
585
+ && !var
586
+ . chars ( )
587
+ . all ( |c| matches ! ( c, 'a' ..='z' | 'A' ..='Z' | '_' ) )
588
+ {
589
+ msg_info. warn ( format_args ! (
590
+ "got {var_type} of \" {var}\" which is not a valid environment variable name. the proper syntax is {var_syntax}"
591
+ ) ) ?;
592
+ * warned = true ;
593
+ }
594
+
577
595
if key == "CROSS_RUNNER" {
578
596
eyre:: bail!(
579
597
"CROSS_RUNNER environment variable name is reserved and cannot be pass through"
@@ -631,12 +649,19 @@ pub(crate) fn docker_envvars(
631
649
dirs : & ToolchainDirectories ,
632
650
msg_info : & mut MessageInfo ,
633
651
) -> Result < ( ) > {
652
+ let mut warned = false ;
634
653
for ref var in options
635
654
. config
636
655
. env_passthrough ( & options. target ) ?
637
656
. unwrap_or_default ( )
638
657
{
639
- validate_env_var ( var) ?;
658
+ validate_env_var (
659
+ var,
660
+ & mut warned,
661
+ "environment variable" ,
662
+ "`passthrough = [\" ENVVAR=value\" ]`" ,
663
+ msg_info,
664
+ ) ?;
640
665
641
666
// Only specifying the environment variable name in the "-e"
642
667
// flag forwards the value from the parent shell
@@ -714,13 +739,21 @@ pub(crate) fn docker_mount(
714
739
paths : & DockerPaths ,
715
740
mount_cb : impl Fn ( & mut Command , & Path , & Path ) -> Result < ( ) > ,
716
741
mut store_cb : impl FnMut ( ( String , String ) ) ,
742
+ msg_info : & mut MessageInfo ,
717
743
) -> Result < ( ) > {
744
+ let mut warned = false ;
718
745
for ref var in options
719
746
. config
720
747
. env_volumes ( & options. target ) ?
721
748
. unwrap_or_default ( )
722
749
{
723
- let ( var, value) = validate_env_var ( var) ?;
750
+ let ( var, value) = validate_env_var (
751
+ var,
752
+ & mut warned,
753
+ "volume" ,
754
+ "`volumes = [\" ENVVAR=/path/to/directory\" ]`" ,
755
+ msg_info,
756
+ ) ?;
724
757
let value = match value {
725
758
Some ( v) => Ok ( v. to_owned ( ) ) ,
726
759
None => env:: var ( var) ,
0 commit comments