We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c2b0a77 commit 24de28fCopy full SHA for 24de28f
rustler_mix/lib/rustler.ex
@@ -158,13 +158,29 @@ defmodule Rustler do
158
:code.purge(__MODULE__)
159
160
{otp_app, path} = @load_from
161
+ app_dir = Application.app_dir(otp_app, path)
162
163
load_path =
- otp_app
164
- |> Application.app_dir(path)
165
- |> to_charlist()
+ case System.get_env("ESCRIPT_NAME") do
+ nil ->
166
+ app_dir
167
+
168
+ escript_path ->
169
+ if String.starts_with?(app_dir, escript_path) do
170
+ tmp = System.tmp_dir!()
171
172
+ :zip.extract(escript_path,
173
+ file_list: [Path.join(otp_app |> Atom.to_string(), path)],
174
+ cwd: tmp
175
+ )
176
177
+ Path.join(tmp, path)
178
+ else
179
180
+ end
181
182
- :erlang.load_nif(load_path, _construct_load_data())
183
+ :erlang.load_nif(load_path |> to_charlist(), _construct_load_data())
184
end
185
186
0 commit comments