@@ -94,17 +94,20 @@ show(io::IO, prefix::Prefix) = show(io, "Prefix($(prefix.path))")
94
94
95
95
96
96
"""
97
- withenv(f::Function, prefixes::Vector{Prefix})
97
+ withenv(f::Function, prefixes::Vector{Prefix}; julia_libdir::Bool = true )
98
98
99
99
Wrapper function designed to help executables find dynamic libraries and child
100
- binaries by wrapping PATH and (DY)LD_LIBRARY_PATH.
100
+ binaries by wrapping PATH and `(DY)LD_(FALLBACK_)LIBRARY_PATH`. If
101
+ `julia_libdir` is true, then the private library directory of this Julia
102
+ distribution will be added on to the end of the LD_LIBRARY_PATH settings.
101
103
"""
102
- function withenv (f:: Function , prefixes:: Vector{Prefix} )
104
+ function withenv (f:: Function , prefixes:: Vector{Prefix} ;
105
+ julia_libdir:: Bool = true )
103
106
# Join `dirs` to ENV[key], removing duplicates and nonexistent directories
104
107
# as we go, normalizing directory names, splitting and joining by `sep`.
105
- function joinenv (key, dirs, sep)
106
- value = [dirs... , split (get (ENV , key, " " ), sep)... ]
107
- return join ([abspath (d) for d in value if isdir (d)], sep)
108
+ function joinenv (key, dirs, sep, tail_dirs = [] )
109
+ value = [dirs... , split (get (ENV , key, " " ), sep)... , tail_dirs ... ]
110
+ return join (unique ( [abspath (d) for d in value if isdir (d)]) , sep)
108
111
end
109
112
# We're going to build up PATH and {DY,}LD_LIBRARY_PATH such that binaries
110
113
# that use things from the given prefixes can function properly.
@@ -113,8 +116,14 @@ function withenv(f::Function, prefixes::Vector{Prefix})
113
116
114
117
# {DY,}LD_LIBRARY_PATH only makes sense on non-windows
115
118
if ! Sys. iswindows ()
116
- envname = Sys. isapple () ? " DYLD_LIBRARY_PATH" : " LD_LIBRARY_PATH"
117
- push! (mapping, envname => joinenv (envname, libdir .(prefixes), " :" ))
119
+ libdirs = libdir .(prefixes)
120
+ tail_dirs = []
121
+ if julia_libdir
122
+ tail_dirs = [joinpath (Sys. BINDIR, Base. PRIVATE_LIBDIR)]
123
+ end
124
+
125
+ envname = Sys. isapple () ? " DYLD_FALLBACK_LIBRARY_PATH" : " LD_LIBRARY_PATH"
126
+ push! (mapping, envname => joinenv (envname, libdirs, " :" , tail_dirs))
118
127
end
119
128
120
129
# Use withenv to apply the calculated environment mappings to f.
0 commit comments