@@ -37,22 +37,45 @@ jl_value_t *checked_eval_string(const char *code) {
3737
3838void set_depot_load_path (const char * root_dir ) {
3939#ifdef _WIN32
40+ char * path_sep = ";" ;
4041 char * julia_share_subdir = "\\share\\julia" ;
4142#else
43+ char * path_sep = ":" ;
4244 char * julia_share_subdir = "/share/julia" ;
4345#endif
44- char * share_dir =
45- calloc (sizeof (char ), strlen (root_dir ) + strlen (julia_share_subdir ) + 1 );
46- strcat (share_dir , root_dir );
47- strcat (share_dir , julia_share_subdir );
46+ int share_path_len = strlen (root_dir ) + strlen (julia_share_subdir ) + 1 ;
47+
48+ char * curr_depot_path = getenv ("JULIA_DEPOT_PATH" );
49+ int curr_depot_path_len = curr_depot_path == NULL ? 0 : strlen (curr_depot_path );
50+ int new_depot_path_len = curr_depot_path_len + 1 + share_path_len ;
51+ char * new_depot_path = calloc (sizeof (char ), new_depot_path_len );
52+ if (curr_depot_path_len > 0 ) {
53+ strcat (new_depot_path , curr_depot_path );
54+ strcat (new_depot_path , path_sep );
55+ }
56+ strcat (new_depot_path , root_dir );
57+ strcat (new_depot_path , julia_share_subdir );
58+
59+ char * curr_load_path = getenv ("JULIA_LOAD_PATH" );
60+ int curr_load_path_len = curr_load_path == NULL ? 0 : strlen (curr_load_path );
61+ int new_load_path_len = curr_load_path_len + 1 + share_path_len ;
62+ char * new_load_path = calloc (sizeof (char ), new_load_path_len );
63+ if (curr_load_path_len > 0 ) {
64+ strcat (new_load_path , curr_load_path );
65+ strcat (new_load_path , path_sep );
66+ }
67+ strcat (new_load_path , root_dir );
68+ strcat (new_load_path , julia_share_subdir );
4869
4970#ifdef _WIN32
50- _putenv_s ("JULIA_DEPOT_PATH" , share_dir );
51- _putenv_s ("JULIA_LOAD_PATH" , share_dir );
71+ _putenv_s ("JULIA_DEPOT_PATH" , new_depot_path );
72+ _putenv_s ("JULIA_LOAD_PATH" , new_load_path );
5273#else
53- setenv ("JULIA_DEPOT_PATH" , share_dir , 1 );
54- setenv ("JULIA_LOAD_PATH" , share_dir , 1 );
74+ setenv ("JULIA_DEPOT_PATH" , new_depot_path , 1 );
75+ setenv ("JULIA_LOAD_PATH" , new_load_path , 1 );
5576#endif
77+ free (new_load_path );
78+ free (new_depot_path );
5679}
5780
5881// main function (windows UTF16 -> UTF8 argument conversion code copied from
0 commit comments