@@ -595,20 +595,31 @@ fn main() {
595
595
env:: remove_var ( "SHARUN_WORKING_DIR" )
596
596
}
597
597
598
+ #[ cfg( feature = "setenv" ) ]
599
+ {
600
+ if let Ok ( dir) = PathBuf :: from ( & library_path) . read_dir ( ) {
601
+ for entry in dir. flatten ( ) {
602
+ let entry_path = entry. path ( ) ;
603
+ if entry_path. is_dir ( ) {
604
+ let name = entry. file_name ( ) ;
605
+ if let Some ( name) = name. to_str ( ) {
606
+ if name. starts_with ( "girepository-" ) {
607
+ env:: set_var ( "GI_TYPELIB_PATH" , entry_path)
608
+ }
609
+ }
610
+ }
611
+ }
612
+ }
613
+ }
614
+
598
615
let lib_path_file = & format ! ( "{library_path}/lib.path" ) ;
599
616
if !Path :: new ( lib_path_file) . exists ( ) && is_writable ( & library_path) {
600
617
gen_library_path ( & library_path, lib_path_file)
601
618
}
602
619
603
620
add_to_env ( "PATH" , bin_dir) ;
604
621
605
- let mut lib_path_data = read_to_string ( lib_path_file) . unwrap_or ( "" . into ( ) ) ;
606
- if !lib_path_data. is_empty ( ) {
607
- lib_path_data = lib_path_data. trim ( ) . into ( ) ;
608
- library_path = lib_path_data
609
- . replace ( "\n " , ":" )
610
- . replace ( "+" , & library_path)
611
- }
622
+ let mut lib_path_data = read_to_string ( lib_path_file) . unwrap_or_default ( ) ;
612
623
613
624
#[ cfg( feature = "setenv" ) ]
614
625
{
@@ -668,9 +679,6 @@ fn main() {
668
679
if dir. starts_with ( "gegl-" ) {
669
680
env:: set_var ( "GEGL_PATH" , dir_path)
670
681
}
671
- if dir. starts_with ( "girepository-" ) {
672
- env:: set_var ( "GI_TYPELIB_PATH" , dir_path)
673
- }
674
682
if dir == "libdecor" {
675
683
let plugins = & format ! ( "{dir_path}/plugins-1" ) ;
676
684
if Path :: new ( plugins) . exists ( ) {
@@ -714,17 +722,7 @@ fn main() {
714
722
}
715
723
}
716
724
}
717
- }
718
-
719
- drop ( lib_path_data) ;
720
-
721
- let ld_library_path_env = & get_env_var ( "LD_LIBRARY_PATH" ) ;
722
- if !ld_library_path_env. is_empty ( ) {
723
- library_path += & format ! ( ":{ld_library_path_env}" )
724
- }
725
725
726
- #[ cfg( feature = "setenv" ) ]
727
- {
728
726
let share_dir = PathBuf :: from ( format ! ( "{sharun_dir}/share" ) ) ;
729
727
if share_dir. exists ( ) {
730
728
if let Ok ( dir) = share_dir. read_dir ( ) {
@@ -814,6 +812,20 @@ fn main() {
814
812
}
815
813
}
816
814
815
+ if !lib_path_data. is_empty ( ) {
816
+ lib_path_data = lib_path_data. trim ( ) . into ( ) ;
817
+ library_path = lib_path_data
818
+ . replace ( "\n " , ":" )
819
+ . replace ( "+" , & library_path)
820
+ }
821
+
822
+ drop ( lib_path_data) ;
823
+
824
+ let ld_library_path_env = & get_env_var ( "LD_LIBRARY_PATH" ) ;
825
+ if !ld_library_path_env. is_empty ( ) {
826
+ library_path += & format ! ( ":{ld_library_path_env}" )
827
+ }
828
+
817
829
for var_name in unset_envs {
818
830
env:: remove_var ( var_name)
819
831
}
0 commit comments