-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for fully custom :load_from
for escripts
#556
Comments
If I understand your question correctly, you are wondering if you should be able to use an absolute path for |
@evnu that is correct. And I also have the question that since I got absolute paths working by changing 2 lines in code, did I just find a bug or is there a reason as to why only relative paths are allowed? |
I think this might be a bug, absolute? = Path.absname(path) == path
load_path =
if absolute? do
to_charlist(path)
else
otp_path |> Application.app_dir(path) |> to_charlist()
end We could also add a separate option @filmor thoughts? |
I support having a separate option for the sake of backward compatibility and for simplifying things in code. Just check if the compiled artifact is present in absolute path, and proceed accordingly. 😄 |
Current state here: @filmor and I discussed a possible solution (simply allowing absolute paths) in #558. The solution has pros (simple) and cons (versioning of the library, deployment of the library, etc). @filmor proposed to implement |
I'm building an application which uses a library built on rustler (ex_git). Because of nix's network sandbox, one cannot rely on the elixir-driven compilation of the rust library. When I tried using
|
Nix can compile other Rust projects as well, right? Rustler's mix integration is basically just a wrapper around |
The problem is that cargo was trying to download the dependencies for the library. If you have to pre-vendor the dependencies, it's just as easy to use nix to build the rust library first and provide the output to the resulting app. I'm open to alternatives, but this does work. In elixir config set config :ex_git, ExGit, skip_compilation?: true then for nix mixNixDeps = import ./mix.nix {
inherit lib beamPackages;
overrides = _: prev: {
ex_git = let
name = "ex_git";
version = "0.11.0";
src = beamPackages.fetchHex {
pkg = "${name}";
version = "${version}";
sha256 = "1lri3xvslkz8m2f65jfkfmqf9b5jjr5r5r865hwlll5bm316s4ck";
};
exgitRustler = rustPlatform.buildRustPackage {
pname = "ex_git_rustler";
inherit version;
nativeBuildInputs = [
pkg-config
];
buildInputs = [
openssl
];
src = "${src}/native/exgit";
cargoHash = "sha256-H2dNNrrz+fc4h7YwLVkyumHTpb5Z3koZ2RwRY2OU3EY=";
};
in
beamPackages.buildMix {
inherit name version src;
beamDeps = [prev.rustler];
appConfigPath = ../config;
postBuild = ''
rm priv/native/libexgit.so
ln -s ${exgitRustler}/lib/libexgit.so priv/native/libexgit.so
'';
};
};
}; |
Hi, I'm trying to use a single rust function inside my elixir app. I followed the setup instructions according to
mix rustler.new
and successfully got it working underiex
. Unfortunately, I was getting an error when doing the same forescript.build
, which is when I found out that rustler uses priv directory which is not accessible to escripts. Luckily, I came across theload_from
configuration option and tried it in my module like this:use Rustler, otp_app: :fizzbuzz, crate: "fizzbuzz", load_from: {:fizzbuzz, "/Users/maheep/Downloads/native/libfizzbuzz"}
Unfortunately, all it does is append the path to Application.app_dir output. Here's the problematic line in
rustler.ex
:which I changed to:
Doing this change allows me to specify fully custom
load_from
paths and gets things working for me.MY QUESTION: Is
load_from
the correct option to use in my case? If so, do I have any other alternative (I don't think its a good idea to mess with a dependency's code).MY OS: macOS 13.4.1 Ventura
The text was updated successfully, but these errors were encountered: