Skip to content

Commit 35ac254

Browse files
committed
Fix julia_bindir calculation when embedding
1 parent 201c18c commit 35ac254

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/init.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,10 +642,16 @@ static void jl_resolve_sysimg_location(JL_IMAGE_SEARCH rel, const char* julia_bi
642642
jl_options.julia_bin = (char*)malloc_s(path_size + 1);
643643
memcpy((char*)jl_options.julia_bin, free_path, path_size);
644644
((char*)jl_options.julia_bin)[path_size] = '\0';
645-
if (!julia_bindir) {
645+
if (julia_bindir == NULL) {
646646
jl_options.julia_bindir = getenv("JULIA_BINDIR");
647647
if (!jl_options.julia_bindir) {
648-
jl_options.julia_bindir = dirname(free_path);
648+
#ifdef _OS_WINDOWS_
649+
jl_options.julia_bindir = strdup(jl_get_libdir());
650+
#else
651+
int written = asprintf((char**)&jl_options.julia_bindir, "%s" PATHSEPSTRING ".." PATHSEPSTRING "%s", jl_get_libdir(), "bin");
652+
if (written < 0)
653+
abort(); // unexpected: memory allocation failed
654+
#endif
649655
}
650656
} else {
651657
jl_options.julia_bindir = julia_bindir;

0 commit comments

Comments
 (0)